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.
Controls in VB Unit 2. Message box One of the best functions in Visual Basic is the message box. The message box displays a message, optional icon, and.
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
SAPScript Forms. SAPScript Form Components SAPScript Form Components A form of the graphical Form Painter consists of five components. In alphanumeric.
Chapter 2, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 2 Creating Applications With Visual Basic.
NOOR RAZA CHEEMA AMINA NAWAZ. GDI+ GDI+ is the next version of GDI. GDI+ drawing has graphics classes that can be used to write graphics on screen.GDI+
XP New Perspectives on Microsoft Office Word 2003 Tutorial 9 1 Microsoft Office Word 2003 Tutorial 9 – Creating On-Screen Forms Using Advanced Table Techniques.
® Copyright 2008 Adobe Systems Incorporated. All rights reserved. ® ® 1 INTRODUCTION TO ADOBE FLASH CS4.
Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition Windows XP Unit A.
03: Basic Principles of 2D Graphics. Lecturer Details Dr. Walid Khedr, Ph.D. Web: Department of Information.
Learning the Basics – Lesson 11 Learning the Basics Lesson 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 2- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Working with Graphics – Lesson 21 Working with Graphics Lesson 2.
Microsoft® Small Basic Responding to Events Estimated time to complete this lesson: 1 hour.
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
BD FACSDiVa 4.1 An introduction. FACSDiVa Software The new digital acquisition platform introduces a complete new software concept from BD The software.
Microsoft® Small Basic Graphics Window Estimated time to complete this lesson: 1 hour.
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
MS Word BasicTraining. Section One: Word Basics Section Objectives Know how to open MS Word. Be able to identify the Toolbar. Know which Tabs on.
Introducing Windows 7. Start Windows and view the desktop Use pointing devices Use the Start button Use the taskbar Work with windows Microsoft Windows.
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
PLEASE USE THE ENTER KEY OR RIGHT CLICK ON THE MOUSE TO ADVANCE.
MT311 (Oct 2006) Java Application Development Tutorial 2 Graphical User Interface.
Creating Online Presentations. Creating a Presentation To create a presentation 1.Open PowerPoint. In the task pane under New select From Design Template,
1 IT Essentials I v. 3 Module 1 Information Technology Basics.
VBA Basic File I/O. VBA includes several objects, methods, and functions that can be used for file I/O One possibility for file I/O The Workbook Object.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
4Left Click on Start 4Slide up to Programs 4Slide right and highlight Microsoft PowerPoint Left Click.
Chapter 9, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 9 Files, Printing, and Structures.
Paragraph Formatting Lesson 4. Objectives Software Orientation The Paragraph dialog box contains Words commands for changing paragraph alignment, indentation,
ENGT 122 – CAD I Title Blocks & Templates PLUS Chapter 7 – Controlling Drawing Display & Creating Text.
© 2016 SlidePlayer.com Inc. All rights reserved.