手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp.Net编程>列表

Microsoft Agent Tutorial Chapter 1

来源:互联网 作者:西部数码 时间:2008-04-10
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

     Merlin.Speak "\Ctx=""Address"\webmaster@abstractvb.com."

Part 5 - Bookmarks

A bookmark is really just another speech output tag, ("Mrk") except for one difference, and that is that there is a special event tied to this tag. The bookmark tag is used to mark specific points in the text supplied to the agents Speak command. Once one of these tags is hit it will fire the BookMark event of the Agent control and pass it the ID you entered in the "Mrk" tag.

To demonstrate how to use bookmarks here is a small application.

You will need to Create a form and place this code in it. You will also need to put a label on the form and call it "Label1".

     Option Explicit
 
     Private WithEvents MSAgent As Agent
     Private Peedy As IAgentCtlCharacterEx
     Private Merlin As IAgentCtlCharacterEx
    
     Private Sub Form_Load()
     ''''Create an Instance of the Agent Control
     Set MSAgent = New Agent
    
     ''''Load the Merlin Character
     MSAgent.Characters.Load "Merlin",
     "c:\windows\msagent\chars\Merlin.acs"
     Set Merlin = MSAgent.Characters("Merlin")
    
     ''''Move the Character to the left
     Merlin.Left = 500
    
     ''''Show Merlin without playing the animation
     Merlin.Show True
    
     ''''Use bookmarks in the text to identify where merlin is
     Merlin.Speak "\Mrk=1\I am now reading line number one. " & _
                  "\Mrk=2\Now I am reading line two. " & _
                  "\Mrk=3\And finally, I am reading line three. \Mrk=4\ "
     End Sub
    
     Private Sub MSAgent_Bookmark(ByVal BookmarkID As Long)
     
     ''''When Merlin hits the point in the text above where
     ''''there is a bookmark tag this event is fired and the
     ''''ID in the Mrk tag is passed into here as the
     ''''BookMark ID
     Select Case BookmarkID
     Case 1
         Form1.Label1.Caption = "Merlin is currently Reading Line 1"

     Case 2
         Form1.Label1.Caption = "Merlin is currently Reading Line 2"

     Case 3
         Form1.Label1.Caption = "Merlin is currently Reading Line 3"

     Case 4
         Form1.Label1.Caption = "Merlin has finished Reading all lines"

     End Select
     End Sub

Part 6 - Animations

(Microsoft provides the complete animation list for all its characters on their website.)

Making the agent perform a specific animation is just one line of code. Try running this:
Merlin.Play "Read"

Notice the agent will read and then stop and go back to the default animation behavior. This is not true for all animations there are some that are called Looping Animations. These animations behave like their name suggests, they loop repeatedly. Try this:
Merlin.Play "Reading"

You will have to stop the above program because the Agent will continuing looping forever. One way to stop this is by using the "Stop" command.

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!