Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia.

Similar presentations


Presentation on theme: "© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia."— Presentation transcript:

1 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia Using Microsoft Agent Outline 27.1 Microsoft Agent 27.2 Downloading Microsoft Agent Components 27.3 Test-Driving the Phone Book Application 27.4 Constructing the Phone Book Application 27.5 Wrap-Up

2 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 Objectives In this tutorial, you will learn to: – Download components necessary to run Microsoft Agent. – Enhance Windows applications using multimedia. – Create applications that interact with users. – Use Microsoft Agent in a C# application.

3 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 3 27.1 Microsoft Agent

4 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 4 27.1 Microsoft Agent Microsoft Agent features: – Speech recognition engine : translates vocal sound input into a language the computer understands – Text-to-speech engine : translates typed words into sounds

5 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 5 27.2 Downloading Microsoft Agent Components You should download and install three files: 1) Peedy.exe from the Microsoft Agent character files link 2) tv_enua.exe from the Microsoft Agent Text-to- speech engines link 3) actcnc.exe from the Microsoft Agent Speech recognition engines link 4) spchapi.exe from the SAPI 4.0 Runtime Support link (required for Windows XP only)

6 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 6 27.2 Downloading Microsoft Agent Components Figure 27.1 Microsoft Web page containing Agent-related downloads. Text-to-speech engines link Character files link Speech-recognition engines link

7 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 7 27.2 Downloading Microsoft Agent Components Figure 27.2 Location for downloading the Microsoft Agent character. Select the Peedy character here

8 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 8 27.3 Test-Driving the Phone Book Application Figure 27.3 Phone Book application Form. Run the application – Debug > Start

9 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 9 27.3 Test-Driving the Phone Book Application Figure 27.4 Peedy appears after Call Peedy Button is clicked. ComboBox disabled until Peedy arrives

10 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 10 27.3 Test-Driving the Phone Book Application Figure 27.5 Peedy in a resting pose.

11 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 11 27.3 Test-Driving the Phone Book Application Figure 27.6 Selecting a name from the ComboBox. Disabled Call Peedy Button Call Peedy Button is disabled after Peedy appears

12 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 12 27.3 Test-Driving the Phone Book Application Figure 27.7 Peedy thinking. Peedy thinks after Howard is selected from the ComboBox

13 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13 27.3 Test-Driving the Phone Book Application Figure 27.8 Peedy communicates Howard’s phone number.

14 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 14 27.3 Test-Driving the Phone Book Application Figure 27.9 Peedy smiles after speaking phone number.

15 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 15 27.3 Test-Driving the Phone Book Application Figure 27.10 Peedy listening for a voice command. Pressing Scroll Lock displays a status box under Peedy Status box

16 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 16 27.3 Test-Driving the Phone Book Application Figure 27.11 Peedy heard voice command.

17 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 17 27.3 Test-Driving the Phone Book Application Figure 27.12 Peedy displays requested phone number. Peedy returning number that corresponds to name spoken

18 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 18 27.3 Test-Driving the Phone Book Application Figure 27.13 Context menu window. Commands in pop-up window Right click Peedy to select one of the names shown – Peedy performs same action resulting from selecting a name from the ComboBox

19 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 19 27.4 Constructing the Phone Book Application Figure 27.14 ACE table for the Phone Book application.

20 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 20 27.4 Constructing the Phone Book Application

21 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 21 27.4 Constructing the Phone Book Application Figure 27.15 Tools menu. To make Microsoft Agent accessible – Windows Forms > Tools > Customize Toolbox… Select Microsoft Agent Control 2.0 from COM Components tab of Customize Toolbox…

22 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 22 27.4 Constructing the Phone Book Application Select CheckBox Figure 27.16 Customize Toolbox dialog.

23 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 23 27.4 Constructing the Phone Book Application Figure 27.17 Agent Control in the Toolbox. Added Agent Control

24 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 24 27.4 Constructing the Phone Book Application Figure 27.18 Form format of Phone Book. Agent control added to Form

25 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 25 27.4 Constructing the Phone Book Application Figure 27.19 Phone Book Form with no functionality.

26 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 26 27.4 Constructing the Phone Book Application Figure 27.20 Rearranging and commenting the new control declaration.

27 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 27 27.4 Constructing the Phone Book Application Figure 27.21 Declaring and creating arrays in Phone Book. Create an Agent character variable List of names in phone book List of phone numbers

28 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 28 27.4 Constructing the Phone Book Application Declaring a counter variable Adding names to the ComboBox Figure 27.22 Adding items to the ComboBox.

29 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 29 27.4 Constructing the Phone Book Application Assigning Peedy to the Agent character variable Loading the Peedy character Figure 27.23 Loading the Microsoft Agent character.

30 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 30 27.4 Constructing the Phone Book Application The Add method takes five arguments: 1) Command name: enables access to the command from your program 2) string that appears in a context window when the user right clicks Peedy 3) string containing words for which Peedy listens when users speak a command 4) bool that specifies whether the command is enabled 5) bool that specifies whether the command is visible in the Commands context menu

31 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 31 27.4 Constructing the Phone Book Application Figure 27.24 Adding commands to Peedy’s context menu. Creating commands so that Peedy can recognize names when spoken

32 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 32 27.4 Constructing the Phone Book Application MoveTo takes three arguments : 1) x-coordinate (type short ) 2)y-coordinate (type short ) 3)Speed (type long, lower number is faster) Convert.ToInt16 converts a value to a short value short data type: like a long data type, but less accurate and uses less memory Cursor.Position stores the current position of the mouse pointer

33 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 33 27.4 Constructing the Phone Book Application Make Peedy fly onto screen Move Peedy Figure 27.25 Displaying the Microsoft Agent character. Create the Button ’s Click event handler

34 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 34 27.4 Constructing the Phone Book Application Make Peedy waveMake Peedy speak instructions Make Peedy rest Figure 27.26 Code that defines Microsoft Agent’s actions when Peedy first appears on the screen.

35 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 35 27.4 Constructing the Phone Book Application Enable the ComboBox and disable the Call Peedy Button Figure 27.27 Disable btnCall after Peedy has appeared on the screen. Set the Call Peedy Button ’s Enabled property to false and cboName ’s Enabled property to true while the Agent character is shown.

36 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 36 27.4 Constructing the Phone Book Application Figure 27.28 Event handler objMainAgent_Command defined Retrieve user input Cast operator converts e.userInput to an object of type AgentObjects.IAgentCtlUserInput so that its members can be accessed properly

37 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 37 27.4 Constructing the Phone Book Application Figure 27.29 Finding the spoken or selected name. Declaring a counter variable Peedy thinks and speaks telephone number, if found The for statement searches the array for the command name.

38 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 38 27.4 Constructing the Phone Book Application Figure 27.30 Event handler cboName_SelectedIndexChanged defined. Declaring a counter variable Peedy thinks and speaks telephone number, if found Event handler executed when the user selects the name from the ComboBox.

39 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 39 27.4 Constructing the Phone Book Application Figure 27.31 Microsoft Agent HideEvent event handler. Reset application controls When the user selects Hide from Peedy’s context menu – E nable the Call Peedy Button

40 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 40 PhoneBook.cs (1 of 9)

41 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 41 PhoneBook.cs (2 of 9) Variable to hold Microsoft Agent character

42 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 42 PhoneBook.cs (3 of 9)

43 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 43 PhoneBook.cs (4 of 9) Loading Peedy Assigning the Peedy character

44 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 44 PhoneBook.cs (5 of 9) Adding commands Showing Peedy Moving Peedy

45 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 45 PhoneBook.cs (6 of 9) Command event handler Convert user input to type AgentObjcets.IAgentCtlUserIn- put Peedy waves and speaks instructions

46 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 46 PhoneBook.cs (7 of 9)

47 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 47 PhoneBook.cs (8 of 9) HideEvent event handler

48 Outline © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 48 PhoneBook.cs (9 of 9)


Download ppt "© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia."

Similar presentations


Ads by Google