Mouse event handling Mouse events( delegates EventHandler, event arguments EventArgs) MouseEnter: raised if the mouse cursor enters the area of the control.

Slides:



Advertisements
Similar presentations
Chapter 9 Color, Sound and Graphics
Advertisements

COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Microsoft Word Penguin Research Lesson 1: Typing, Font, Inserting Pictures and Inserting Textboxes.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
© by Pearson Education, Inc. All Rights Reserved. continued …
Mouse event handling Mouse events( delegates EventHandler, event arguments EventArgs) MouseEnter: raised if the mouse cursor enters the area of the control.
PictureBoxes A picture box displays an image. You can find it in toolbox, drag it in the form Images can be.bmp,.gif,.jpg, jpeg GIF and JPEG files are.
Flowchart Start Input weight and height
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
Events. Events Single Event Handlers Click Event Mouse Events Key Board Events Create and handle controls in runtime Outline.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
PictureBox, Timer, Resources. Resources An easy and effective way to add pictures (photos, graphics) to your programs Using Resources guarantees that.
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
CSCI 3327 Visual Basic Chapter 10: Windows Forms GUI: A Deeper Look UTPA – Fall 2011.
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
IE 411/511: Visual Programming for Industrial Applications
BIM211 – Visual Programming Objects, Collections, and Events 1.
Microsoft Word 2000 Presentation 5. Major Word Topics Columns Tables Lists.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 2 Creating Applications With Visual Basic.NET.
Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
BIL528 – Bilgisayar Programlama II Introduction 1.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
Visual Basic.NET BASICS Lesson 3 Events and Code.
Microsoft Expression Web-Illustrated Unit E: Working with Pictures.
BIM211 – Visual Programming Interacting with Users Graphics 1.
Animating GIF. What is it? Think of how a flip book works. Each page is a different picture and when flipped through quickly, it looks as though objects.
CC111 Lec7 : Visual Basic 1 Visual Basic(1) Lecture 7.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
COMPUTER PROGRAMMING I SUMMER 2011 Objective 8.02 Apply Procedures to Create Picture Boxes using Images. (5%)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
How to Resize and Crop Pictures Easily in Microsoft Paint Ammar Rai ENGL 393.
Presented By: Weidong WU, Ph.D. Date: Part I Creating a drawing format for the paper size A (11 x 8.5) 1. Start Pro/E wildfire. 2. File  set.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
1 Mapping Coordinates Find the x- and y- coordinates for the images, relative to the x-axis and y-axis In a coordinate pair, the first number is the x-coordinate.
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.
E-Board Features North Dakota University System 2008.
 2002 Prentice Hall. All rights reserved. 1 Outline Mouse Event Handling Keyboard Event Handling Graphical User Interface Concepts:
Microsoft PowerPoint Prepared by the Academic Faculty Members of IT.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
1 Windows Forms II Chapter RadioButton / GroupBox Controls Used to solicit a multiple choice input. Radio buttons work as a group. Selecting one.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Dr. Abraham Professor UTPA Graphical User Interface.
 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.
2-1 Chapter 2 Using VB.NET to Create a First Solution.
Graphical User Interface Concepts - Part 1 Session 08 Mata kuliah: M0874 – Programming II Tahun: 2010.
Chapter 1: An Introduction to Visual Basic .NET
Computing with C# and the .NET Framework
Microsoft Access 2007 – Level 2
Introduction to Computer CC111
Object Oriented Programming
Chapter 2 – Introduction to the Visual Studio .NET IDE
Program and Graphical User Interface Design
Objective 8.02 Apply Procedures to Create Picture Boxes using Images.
Computer Programming I
Program and Graphical User Interface Design
Simple Windows Applications
Presentation transcript:

Mouse event handling Mouse events( delegates EventHandler, event arguments EventArgs) MouseEnter: raised if the mouse cursor enters the area of the control MoueLeave: raised if the mouse cursor leaves the area of control

Mouse events(delegates MouseEventHandler, event arguments MouseEventArgs) MouseDown:raised if the mouse button is pressed while its cursor is over the area of the control MouseHover:Raised if the mouse cursor hovers over the area of the control MouseMove: Raised if the mouse cursor is moved while in the area of the control MouseUp: Raised if the mouse button is released when the cursor is over the area of the control

MouseEventArgs properties Button: Mouse button that was pressed(left, right, middle or none) Clicks: the number of times the mouse button (either mouse button) was clicked X: the x-coordinate of the event, relative to the control Y: the y-coordinate of the event, relative to control

PictureBoxes A picture box displays an image. You can find it in toolbox, drag it in the form Images can be.bmp,.gif,.jpg, jpeg GIF and JPEG files are widely used image file format Properties  Image: image to display in the picture box  SizeMode: controls image sizing and positioning

SizeMode Normal: (default) puts image in top-left corner of picture box StretchImage:resizes image to fit in picture box CenterImage: puts image in middle AutoSize: resizes picture box to hold image

Design GUI Design GUI that contains one PictureBox and three labels( labels show name of the images, set the anchor property of the PictureBox so that it resize when the form resize

MouseEnter, MouseLeave Write proper code so that When mouse enter the first label, the pictureBox will show the first picture When mouse enter the second label, it will show the second picture When mouse enter the third label, it will show the third label

Set the image property To set the image property to an image file imagePictureBox->Image = Image::FromFile(String::Concat(Directory::GetCurre ntDirectory(), S”\\image\\myboy.jpeg”) ; Where imagePictureBox is the name of control (The PictureBox) Directory::GetCurrentDirectory() retrieve the current directory name, ie. Where your project is created image is the folder where all image file are stored. myboy.jpeg is an example of image file name

MouseEnter to the first Label Assume the first Label has name lb_pic1, picture Box has name pic1 Go to property window, click the list of event, and double click on the event MouseEnter private: System::Void lb_pic1_MouseEnter(System::Object *sender, System::Windows::EventArg *e) { pic1->Image = Image::FromFile(String::Concat(Directory::GetCurre ntDirectory(), S\\image\\Myboy.jpeg);\\image\\Myboy.jpeg }

Graphics Create a Graphics class object and use it to draw on the form Graphics *graphic = CreateGraphics(); Methods of Graphics  FillEllipse draws an ellipse  It takes 5 arguments SolidBrush object which determine the color of the shape drawn X coordinator of center position Y coordinator of center position X axis of ellipse Y axis of ellipse graphics->FillEllipse(new SolidBrush(Color::BlueViolet), e->X, e->Y,4,4);

More drawing methods FillPie(SolidBrush, int,int,int,int,int,int) FillRectangle(Brush, int,int,int,int); drawEllipse( …) drawCurve(…) drawPolygon(…) drawRetangle(…)