We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byDillon Kingdon
Modified about 1 year ago
Chapter 9 Color, Sound and Graphics Key Concepts: Applying color to GUI Using images in applications Using Sounds in applications Using Graphics class © 2012 EMC Publishing, LLC Slide 1
© 2012 EMC Publishing, LLC Slide 2 Chapter 9 Using Color Color can enhance an application interface. Control objects have BackColor and ForeColor properties. Visual Basic color constants can be used to change background and foreground colors at run time. BackColor and ForeColor can be chnaged at runtime: see synthax in Notes
© 2012 EMC Publishing, LLC Slide 3 Chapter 9 The Color Dialog Box Predefined dialog box that allows the user to select a color.
© 2012 EMC Publishing, LLC Slide 4 Chapter 9 The ColorDialog Control Properties include: Color is the color selected in the dialog box. AllowFullOpen allows the user to create a custom color. The Color dialog box is displayed using the ShowDialog() method.
© 2012 EMC Publishing, LLC Slide 5 Chapter 9 Using Images Most objects have a BackgroundImage property. The Button and Label control objects have an Image property. Images can be changed at run time using the My.Resources object: Me.btnEvents.Image = My.Resources.Flower Me.BackgroundImage = My.Resources.Balloons
© 2012 EMC Publishing, LLC Slide 6 Chapter 9 The SystemSounds Class Includes five properties for making Windows operating system sounds: Asterisk Beep Exclamation Hand Question The Play() method is used to make the sound: SystemSounds.Beep.Play() Applications require the Imports System.Media statement before any declaration
© 2012 EMC Publishing, LLC Slide 7 Chapter 9 Playing Sound Files Visual Basic applications can play Windows WAV audio files. My.Computer.Audio objects includes the Play() and Stop() methods for working with WAV files. -Play(resource, playmode) -Stop() Audio files must be added to the Resources folder for an application to access them.
© 2012 EMC Publishing, LLC Slide 8 Chapter 9 The Timer Control Applications often perform actions at regular intervals. The Timer object is used to execute code at regular intervals Add from the Tollbox to the component tray
© 2012 EMC Publishing, LLC Slide 9 Chapter 9 The Timer Control Properties include: (Name) should begin with tmr. Interval is the amount of time that passes before the Tick event procedure executes. Enabled allows a Tick event to occur at the end of each interval. Methods include Start() and Stop().
© 2012 EMC Publishing, LLC Slide 10 Chapter 9 Animation Uses a timer control object and a set of images. Images are cycled in a PictureBox control object to give the impression of motion. A Case statement can be used to determine which image to display.
© 2012 EMC Publishing, LLC Slide 11 Chapter 9 The Graphics Class Includes numerous methods for creating lines, shapes, solid shapes, and curves and polygons. Methods require that a drawing surface be defined. Dim formSurface as Graphics=Me.CreateGraphics - This creates a Graphics object from the surface of the form - CreateGraphics method is a control class method that encases a specific’s object area
© 2012 EMC Publishing, LLC Slide 12 Chapter 9 The Graphics Class Methods require that a Pen object be defined. Pen styles can be solid, dashed, and dotted. There are numerous colors to choose from. Dim thinAquaPen As New Pen(Color.Aqua, 2) - the keyword New declares a new object - ColorAqua is a Visual Basic color constant - 2 is the thickness of the line
© 2012 EMC Publishing, LLC Slide 13 Chapter 9 The Graphics Class A drawing surface can be thought as a grid consisting of a set of points with (x, y) values Each point is a pixel ( picture element ) and the number of pixels in a surface depends on the screen resolution. The point with coordinates (0, 0)is the pixel in the very upper-left corner Methods can accept coordinates in (x1, y1), (x2, y2) format or as Point structures that define each point.
The Graphics Class The Size property of an object stores both height and width. For many objects ( labels, buttons…)the height and the width correspond to the coordinates of point in the lower right of the object For a Form object the Size property returns the size of the form Dim formMaxX As Integer = Me.Size.Width ‘300 Dim formMaxX As Integer = Me.Size.Width ‘300 Dim formMaxY as Integer = Me.Size.Height ‘300 Dim formMaxY as Integer = Me.Size.Height ‘300 Returns the Form’s Size property data. © 2012 EMC Publishing, LLC Slide 14
© 2012 EMC Publishing, LLC Slide 15 Chapter 9 The Graphics Drawing Surface A form's drawing surface is reduced by the title bar and borders. Each square on the grid represents 10 pixels. Counting the grid marks show that although the form size is 300 by 300, the actual drawing surface is less, about 292 by 265.
© 2012 EMC Publishing, LLC Slide 16 Chapter 9 The Graphics Class The Graphics class methods require a pen along with the shape position and size. Graphics methods include: DrawLine(pen,x1,y1,x2,y2)->line from(x1, y1) to (x2, y2) DrawRectangle(x1,y1,width,height)-> draws rectangle with upper-left corner at (x1,y1) and size width x height DrawEllipse(x1,y1,width,height)-> draws an ellipse within a rectangular area that has upper-left corner at (x1,y1) and size width x height
© 2012 EMC Publishing, LLC Slide 17 Chapter 9 The Graphics Class DrawArc(pen,x1,y1,width,height,startAngle,sweepAn gle) ->draws an arc tha starts at angle startAngle and continues clockwise sweepAngle degrees. The arc is within a rectangular area that has its upper-left corner at (x1,y1) on a Graphics object with width ang height Clear(color)-> clears the drawing surface with “color”which can be a System.Drawing color constant or the current object color
© 2012 EMC Publishing, LLC Slide 18 Chapter 9 The Graphics Class The shapes in the TestGraphics application have been drawn using absolute coordinates, meaning that actual sizes were used to specify the shape sizes Relative coordinates are another option. They are relative to the size of the form. If the form is resized the shapes maintain their relative size and position. See DrawShapes program and change Form’s size. The Pen class contains the DashStyle property: dashed lines, dotted lines and dash-dot are a few examples.
© 2012 EMC Publishing, LLC Slide 19 Chapter 9 Drawing Solid Shapes The Graphics class methods that fill shapes require a brush along with the shape position and size.: Dim purpleBrush as New SolidBrush(Color.BlueViolet) FillRectangle(brush,x1,y1,width,height) FillEllipse(brush,x1,y1,width,height) FillPie(brush,x1,y1,width,height,startAngle,sweepAngle) The parrameters of the methods are the same as corresponding Draw methods.
© 2012 EMC Publishing, LLC Slide 20 Chapter 9 The Point Structure A point has an x-coordinate a y-coordinate A Point structure can be defined with X and Y members: Dim minPoint As Point minPoint.X=0 minPoint.Y=0 Or Dim minPoint as New Point(0, 0)
© 2012 EMC Publishing, LLC Slide 21 Chapter 9 Drawing curves and Polygons DrawCurve(pen, points) DrawClosedCurve(pen, points) FillClosedCurve(brush, points) DrawPolygon(pen, points) FillPolygon(brush, points)
© 2012 EMC Publishing, LLC Slide 22 Chapter 9 The MouseDown Event Occurs when the user clicks the form or object associated with the MouseDown event. Select Code window, click the object name in the Class Name list and then select MouseDown in the Method Name list The e parameter includes X and Y properties specific to the mouse click that raised the event. The X and Y properties can be used to determine the coordinates of the mouse click.
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Images Part 11 dbg. 2 Images The form and several controls can display a number of different types of image files in the BackgroundImage Property. These.
Lecture Set 13 Drawing Mouse and Keyboard Events Part A - Drawing.
Chapter 13 Graphics, Animation, Sound, and Drag-and-Drop Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
T U T O R I A L 2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Graphics Images – PictureBox control Drawing graphics - Graphics object Multimedia controls PictureBox control Image property – select image Choose how.
1 Chapter 26 D&D – Graphics Outline 26.1 Introduction 26.3 Graphics Contexts and Graphics Objects 26.4 Color Control 26.5 Font Control 26.6 Drawing Lines,
1 Chapter 2 – Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
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.
BIM211 – Visual Programming Objects, Collections, and Events 1.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Objects 9.4 Graphics.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
© by Pearson Education, Inc. All Rights Reserved. continued …
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
2 Part II Enhancing a Presentation Changing the Presentation Design Design template Professionally created slide designs contain –Color schemes –Custom.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 13 Graphics, Animation, Sound and Drag-and-Drop.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
Microsoft® Small Basic Graphics Window Estimated time to complete this lesson: 1 hour.
(C) 2010 Pearson Education, Inc. All rights reserved. Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Events with Data Arguments Data Values Travel with e.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 6A Methods (Concepts)
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
®® Microsoft Windows 7 for Power Users Tutorial 2p1 Customizing Microsoft Windows 7.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 6B Methods (Tutorial)
Chapter 3 Working with Symbols and Interactivity.
Merete S COLLEGEFACULTY OF ENGINEERING & SCIENCE Graphics ikt403 – Object-Oriented Software Development.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 14. Copyright 2003, Paradigm Publishing Inc. CHAPTER 14 BACKNEXTEND 14-2 LINKS TO OBJECTIVES Add Borders with Borders Button Add Borders with.
IT 211 Graphics and Multimedia Part #2 Lab #10. Introduction C# language contains many sophisticated drawing capabilities as part of namespace System.Drawing.
16.9 Introduction to Multimedia Visual Basic offers many convenient ways to include images and animations in programs Computing field decades ago mainly.
BIM211 – Visual Programming Interacting with Users Graphics 1.
You won’t write a single line of program code. Instead, you’ll use visual programming techniques. Visual Studio processes your actions (such as mouse.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Programs 9.4 Graphics.
Chapter 15 Graphics and Java 2D™ Java How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved.
© 2017 SlidePlayer.com Inc. All rights reserved.