using system;
using system.drawing;
using system.winforms;
using agentobjects;
public class hello: form
{
private system.componentmodel.container components;
private system.winforms.button button2;
private system.winforms.button button1;
private system.winforms.textbox textbox1;
private axagentobjects.axagent axagent;
private iagentctlcharacterex character;
public hello()
{
initializecomponent();
}
public static void main(string[] args)
{
application.run(new hello());
}
private void initializecomponent()
{
this.components = new system.componentmodel.container();
this.button1 = new system.winforms.button();
this.button2 = new system.winforms.button();
this.textbox1 = new system.winforms.textbox();
this.axagent = new axagentobjects.axagent();
axagent.begininit();
button2.click += new system.eventhandler(button2_click);
button1.location = new system.drawing.point(88, 208);
button1.backcolor =
(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)128, (byte)128);
button1.size = new system.drawing.size(152, 32);
button1.tabindex = 1;
button1.text = "load character";
button2.location = new system.drawing.point(120, 240);
button2.backcolor =
(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)128, (byte)128);
button2.size = new system.drawing.size(96, 24);
button2.tabindex = 2;
button2.text = "speak";
textbox1.location = new system.drawing.point(48, 8);
textbox1.text = " ";
textbox1.multiline = true;
textbox1.tabindex = 0;
textbox1.size = new system.drawing.size(248, 200);
textbox1.backcolor =
(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)128, (byte)128);
this.text = "msagent demo";
this.autoscalebasesize = new system.drawing.size(5, 13);
this.windowstate = system.winforms.formwindowstate.maximized;
this.backcolor =
(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)192, (byte)192);
this.clientsize = new system.drawing.size(344, 301);
this.controls.add(button2);
this.controls.add(button1);
this.controls.add(textbox1);
this.controls.add(axagent);
button1.click += new system.eventhandler(button1_click);
axagent.endinit();
}
protected void button2_click(object sender, system.eventargs e)
{
if(textbox1.text.length == 0)
return;
character.speak(textbox1.text, null);
}
protected void button1_click(object sender, system.eventargs e)
{
openfiledialog openfiledialog = new openfiledialog();
openfiledialog.addextension = true;
openfiledialog.filter = "microsoft agent characters (*.acs)|*.acs";
openfiledialog.filterindex = 1 ;
openfiledialog.restoredirectory = true ;
if(openfiledialog.showdialog() != dialogresult.ok)
return;
try { axagent.characters.unload("characterid"); }
catch { }
axagent.characters.load("characterid", (object)openfiledialog.filename);
character = axagent.characters["characterid"];
character.languageid = 0x409;
character.show(null);
character.play ("announce");
character.speak ("welcome you sir",null);
}
} |