Lecture 4 Advanced Topics Devi, Erick, Reddy. » Declare dynamic component, an example: ˃Create a button Button newBtn = new Button(); ˃Create an array.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Advertisements

CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
YILAN ATILGAN DAĞILGAN Flow Diagram Of The Program Home Screen Choose Difficulty Start Direction of the Snake DeathStop Show Score Yes No.
Benchmark and Java Applet Test Scenario Presentation Outline Introduction to Benchmark Testing Procedure to create the test Benchmark Playback Results.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Eight Sub and Function Procedures.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Tutorial 15 Working with the Event Model. XP Objectives Compare the IE and W3C event models Study how events propagate under both event models Write a.
Programming Based on Events
Events. Events Single Event Handlers Click Event Mouse Events Key Board Events Create and handle controls in runtime Outline.
Events (Listeners/Handlers: Mouse, keyboard, timer) Flash ActionScript 3.0 Introduction to Thomas Lövgren, Flash developer
Dr Dat Tran - Week 4 Lecture Notes 1 MenuStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
CST238 Week 6 Questions / Concerns? Announcements – HW#2 due next Monday (project concept/preliminary design) – Check-off Take Home lab#5 Comment about.
CSCI 3327 Visual Basic Chapter 10: Windows Forms GUI: A Deeper Look UTPA – Fall 2011.
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Data Binding to Controls Programming in C# Data Binding to Controls CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Visual Basic Games: Week 3 Global variables, parameters, Select, KeyDown Enable, Visible, Focus State of Game Read chapter 3.
Events and Timers. Event handlers ScratchC#/VS 2 Script == event handler.
CSC 298 Windows Forms.
Animation and Double-Buffering. The animation methods described here are based on standard techniques of double-buffering applicable to most high-level.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
C# Events and WPF #W5. Horizontal Prototype WPF Designed for rapid user interface design Used for many devices: Windows Phone, Tablets, PCs,
UNIVERSITY of GREENWICH 1E. I. Teodorescu Dependency/Attached properties Enumerations Starting a game – flying pig Visual Application Development E. I.
Dr Dat Tran - Week 4 Lecture Notes 1 ToolStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
Processing Lecture.2 Mouse and Keyboard
G RAPHICAL U SER I NTERFACE C ONCEPTS : P ART 1 1 Outline Introduction Windows Forms Event-Handling Model - Basic Event Handling.
CSE 251 Dr. Charles B. Owen Programming in C1 States and State Machines.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 - Graphical User Interface Concepts: Part.
Visual C# 2012 How to Program 1. 2  A graphical user interface (GUI) allows a user to interact visually with a program.  Figure 14.1 shows a Visual.
Timer, Animation Responding to Mouse & Keyboard Lab 7 7 McGraw-Hill© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
VB.NET Additional Topics
Arrays Code: Arrays Controls: Control Arrays, PictureBox, Timer.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
Events with Data Arguments Data Values Travel with e.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
COM148X1 Interactive Programming Lecture 7. Topics Today HCI Event Handling.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
Events (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Roy McElmurry. More:
CS 101 Test 2 Study Guide Acronyms RAD - Rapid Application Development IDE - Integrated Development Environment GUI - Graphical User Interface VB - Visual.
Dr Dat Tran - Week 2 Lecture Notes 1 Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences & Engineering.
Events with Data Arguments Data Values Travel with e.
MIS333k(Poynor) Chapter 2. Intro to VBA Events Where to plug in your programs?
Today we are learning to: Understand how flow charts are used to design games Add events to our objects to control stuff in our game – (Using the user.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Enhanced Inventory Application.
Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please.
Events Programming in C# Events CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
 2002 Prentice Hall. All rights reserved. 1 Outline Mouse Event Handling Keyboard Event Handling Graphical User Interface Concepts:
Week 7: Debugging and Error Handling Debugging methods available in the ID Error-handling techniques available in C#
1 Working with Controls at Run Time. 2 Objectives You will be able to Add controls to a Windows form at run time. Modify controls at run time.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
Timed Math Quiz. In This Part, You Learn How to Generate random numbers by using the Random class. Trigger events to occur at a specific time by using.
Chapter 1: An Introduction to Visual Basic .NET
INF230 Basics in C# Programming
Computing with C# and the .NET Framework
Chapter Eleven Handling Events.
Computer Programming I
Chapter 1: An Introduction to Visual Basic 2015
Visual Basic Properties, Methods and Events
Simple Windows Applications
Visual Basic: Week 5 Review User defined functions
Additional Topics in VB.NET
MsgBox, InputBox, and other Day 7 stuff.
Chapter 13: Handling Events
Creating Controls Dynamically in C#
05 | Capturing User Input Michael “Mickey” MacDonald | Indie Game Developer Bryan Griffiths | Software Engineer/Game Developer.
Presentation transcript:

Lecture 4 Advanced Topics Devi, Erick, Reddy

» Declare dynamic component, an example: ˃Create a button Button newBtn = new Button(); ˃Create an array of to-be-filled-with-buttons Button[] newBtn = new Button[4];

» Set Properties: newBtn[0] = new Button(); newBtn[0].Text = "halo"; newBtn[0].Left = 0; this.Controls.Add(newBtn[0]);

» Add event for dynamic component: newBtn[0].Click += new EventHandler(oke); void oke(object sender, EventArgs e) { Button xx= (Button) sender; MessageBox.Show(xx.Text ); }

» Windows Forms provides two events that occur when a user presses a keyboard key and one event when a user releases a keyboard key: ˃The KeyDown event occurs onceKeyDown ˃The KeyPress event, which can occur multiple times when a user holds down the same key.KeyPress ˃The KeyUp event occurs once when a user releases a key.KeyUp

public Form1() { InitializeComponent(); this.KeyPress += new KeyPressEventHandler(Form1_KeyPress); } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { MessageBox.Show(e.KeyChar.ToString()); } Ubah KeyPreview menjadi true, agar event ditangkap oleh Form

private void TextBox1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: //Do stuff break; case Keys.Down: //Do stuff break; case Keys.Left: //Do stuff break; case Keys.Right: //Do stuff break; }

Random rnd = new Random(); » Create a number between 1 and 12 int month = rnd.Next(1, 13); » Create a number between 1 and 6 (inclusive) int dice = rnd.Next(1, 7); » Create a number between 0 and 51 (inclusive) int card = rnd.Next(52);

» Starts raising the Elapsed event by setting Enabled to true.ElapsedEnabled Timer1.Start » Gets or sets the interval at which to raise the Elapsed event.Elapsed Timer1.Interval » Stops raising the Elapsed event by setting Enabled to false.ElapsedEnabled Timer1.Stop

System.Timers.Timer aTimer = new System.Timers.Timer(); » Hook up the Elapsed event for the timer. aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); » Set the Interval to 2 seconds (2000 milliseconds). aTimer.Interval = 2000; aTimer.Enabled = true;

Make a simple Arkanoid Game using buttons like this figure: