コード例 #1
0
        /// <summary>
        /// Ask agent to speak
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSpeak_Click(object sender, System.EventArgs e)
        {
            AgentServer Srv = new AgentServer();

            if (Srv == null)
            {
                MessageBox.Show("ERROR: Agent Server couldn't be started!");
            }

            IAgentEx SrvEx;

            // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object
            SrvEx = (IAgentEx)Srv;

            // First try to load the default character
            int dwCharID = 0, dwReqID = 0;

            try
            {
                // null is used where VT_EMPTY variant is expected by the COM object
                String strAgentCharacterFile = null;
                if (!strFileName.Equals(string.Empty))
                {
                    //Get the acs path
                    strAgentCharacterFile = strPath + strFileName;
                }
                else
                {
                    MessageBox.Show("Select Style");
                    return;
                }

                if (TxtSpeakInput.Text.Equals(string.Empty))
                {
                    TxtSpeakInput.Text = "Please enter text in textbox";
                }
                SrvEx.Load(strAgentCharacterFile, out dwCharID, out dwReqID);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to load Agent character! Exception details:");
            }

            SrvEx.GetCharacterEx(dwCharID, out CharacterEx);

            //CharacterEx.SetLanguageID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));

            // Show the character.  The first parameter tells Microsoft
            // Agent to show the character by playing an animation.

            // Make the character speak
            // Second parameter will be transferred to the COM object as NULL
            CharacterEx.Speak(TxtSpeakInput.Text, null, out dwReqID);
        }
コード例 #2
0
        /// <summary>
        /// Show Agent
        /// </summary>
        private void ShowAgent()
        {
            AgentServer Srv = new AgentServer();

            if (Srv == null)
            {
                MessageBox.Show("ERROR: Agent Server couldn't be started!");
            }

            IAgentEx SrvEx;

            // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object
            SrvEx = (IAgentEx)Srv;

            // First try to load the default character
            int dwCharID = 0, dwReqID = 0;

            try
            {
                // null is used where VT_EMPTY variant is expected by the COM object
                String strAgentCharacterFile = null;
                if (!strFileName.Equals(string.Empty))
                {
                    //Get the acs path
                    strAgentCharacterFile = strPath + strFileName;
                }
                else
                {
                    MessageBox.Show("Select Style");
                    return;
                }

                if (TxtSpeakInput.Text.Equals(string.Empty))
                {
                    TxtSpeakInput.Text = "Please enter text in textbox";
                }

                //load the acs file
                SrvEx.Load(strAgentCharacterFile, out dwCharID, out dwReqID);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to load Agent character! Exception details:");
            }

            SrvEx.GetCharacterEx(dwCharID, out CharacterEx);
            //show the agent
            CharacterEx.Show(0, out dwReqID);
        }