CÁC GIẢI PHÁP LẬP TRÌNH C# - Trang 343

343

Chương 8: Đồ họa, đa phương tiện, và in ấn

voiceString = voiceString.Replace("_", "underscore");

actionsCombo.Items.Add(enumerator.Current);

mSpeaker.Commands.Add(Convert.ToString(enumerator.Current), ""

voiceString, true, false);

}

// Thêm lệnh tùy biến.

mSpeaker.Commands.Add("MoveToMouse", "MoveToMouse",

"Move To Mouse", true, true);

}

finally

{

Monitor.Exit(synclockObject);

}

}

// Phương thức thụ lý sự kiện SelectedIndexChanged của actionsCombo

// (người dùng chọn hành động mới).

private void actionsCombo_SelectedIndexChanged(System.Object sender,

System.EventArgs e)

{

mSpeaker.Stop(null);

mSpeaker.Play(actionsCombo.Text);

mSpeaker.Play("RestPose");

}

// Phương thức thụ lý sự kiện Command của agent.

private void mainAgent_Command(System.Object sender,

AxAgentObjects._AgentEvents_CommandEvent e)

{

AgentObjects.IAgentCtlUserInput command =

((AgentObjects.IAgentCtlUserInput)(e.userInput));

// Đổi nhân vật nếu người dùng đọc tên nhân vật.

if (command.Voice == "Peedy" || command.Voice == "Robby" ||

command.Voice == "Merlin" || command.Voice == "Genie")