有时为了提高客户体验,往往会在程序中增加帮助系统,当年OfficeXP提供了一种叫助手精灵的帮助插件,一个小老头来帮助用户使用Office。现在Win7了,直接使用以往的Ms Agent来开发老头做使用帮助的话,会出现不兼容的情况(即使安装了MS的兼容包,老头也不是透明的,会有粉色的背景。)。当然,也可以选择自己用不规则窗体开发一个精灵老头,只不过种类繁多的魔法动作就难以实现了。不过还好,国外有人已经把Ms Agent修改了为兼容Win7的DoubleAgent。这里给出下载连接:X86版的DoubleAgent。
下载后即可安装,至于那些精灵的文件,网上有很多,MS官网有4种基本精灵的文件:
另外还有个地址有一些用户个人开发的精灵文件:不过个人看,还是老头顺眼点。
http://www.msagentring.org/chars.aspx
把DoubleAgent和精灵安装后,就可以在代码中使用了。首先引用DoubleAgent的组件:Double Agent ActiveX Control,拖动出来的实例为axDaControl系列。
DoubleAgent的使用方法和Ms Agent完全一样,另外安装包中还给了Doc,可以参考。
另外给出我简单写的一个DoubleAgent使用类的代码。代码中DoubleAgent的加载精灵在MainForm的单件中。
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using
System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StreetControlSystem.UI
{
public static class HelpHand
{
private static string [] Roles = { " Merlin " , " Robby " , " Genie " , " Peedy " };
private static string [] Actions = { " RestPose " , " Wave " , " DontRecognize " , " Uncertain " , " Decline " , " Sad " , " StopListening " , " GetAttention " ,
" GetAttentionReturn " , " Blink " , " Idle3_2 " , " Surprised " , " Congratulate_2 " , " Reading " , " Announce " ,
" Read " , " ReadReturn " , " Idle2_2 " , " Writing " , " Write " , " WriteReturn " , " Congratulate " , " Confused " ,
" Suggest " , " MoveRight " , " MoveLeft " , " Idle2_1 " , " MoveUp " , " MoveDown " , " StartListening " , " WriteContinued " ,
" DoMagic1 " , " DoMagic2 " , " Idle1_1 " , " LookDown " , " LookDownBlink " , " LookDownReturn " , " LookLeft " ,
" LookLeftBlink " , " LookLeftReturn " , " Idle1_3 " , " LookRight " , " LookRightBlink " , " LookRightReturn " ,
" LookUp " , " LookUpBlink " , " LookUpReturn " , " Idle1_2 " , " ReadContinued " , " Pleased " , " GetAttentionContinued " ,
" Process " , " Search " , " Think " , " Idle1_4 " , " Greet " , " Idle3_1 " , " GestureUp " , " GestureDown " , " GestureLeft " ,
" GestureRight " , " Show " , " Hide " , " Hearing_4 " , " Hearing_1 " , " Hearing_2 " , " Hearin " , " Alert " , " Explain " ,
" Processing " , " Thinking " , " Searching " , " Acknowledge " };
public static void ChangeRoles( int i_role)
{
MainForm.Character = MainForm.Singleton.axDaControl1.Characters[Roles[i_role]];
}
public static void Hide()
{
MainForm.Character.Hide( null );
}
public static void Show()
{
MainForm.Character.Show( null );
}
public static void Speak( string str)
{
MainForm.Character.Speak(str, null );
}
public static void PlayRandom()
{
Random rdm = new Random(DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Second + DateTime.Now.Minute + DateTime.Now.Millisecond);
int i_rnd = rdm.Next() % Actions.Length;
MainForm.Character.Play(Actions[i_rnd]);
}
public static void SpeakWithAct( string str)
{
Speak(str);
PlayRandom();
}
public static void MoveTo( int x, int y)
{
MainForm.Character.MoveTo(( short )x, ( short )y, null );
}
public static void Move( int x, int y)
{
MainForm.Character.MoveTo(( short )(MainForm.Character.Left + x), ( short )(MainForm.Character.Height + y), null );
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StreetControlSystem.UI
{
public static class HelpHand
{
private static string [] Roles = { " Merlin " , " Robby " , " Genie " , " Peedy " };
private static string [] Actions = { " RestPose " , " Wave " , " DontRecognize " , " Uncertain " , " Decline " , " Sad " , " StopListening " , " GetAttention " ,
" GetAttentionReturn " , " Blink " , " Idle3_2 " , " Surprised " , " Congratulate_2 " , " Reading " , " Announce " ,
" Read " , " ReadReturn " , " Idle2_2 " , " Writing " , " Write " , " WriteReturn " , " Congratulate " , " Confused " ,
" Suggest " , " MoveRight " , " MoveLeft " , " Idle2_1 " , " MoveUp " , " MoveDown " , " StartListening " , " WriteContinued " ,
" DoMagic1 " , " DoMagic2 " , " Idle1_1 " , " LookDown " , " LookDownBlink " , " LookDownReturn " , " LookLeft " ,
" LookLeftBlink " , " LookLeftReturn " , " Idle1_3 " , " LookRight " , " LookRightBlink " , " LookRightReturn " ,
" LookUp " , " LookUpBlink " , " LookUpReturn " , " Idle1_2 " , " ReadContinued " , " Pleased " , " GetAttentionContinued " ,
" Process " , " Search " , " Think " , " Idle1_4 " , " Greet " , " Idle3_1 " , " GestureUp " , " GestureDown " , " GestureLeft " ,
" GestureRight " , " Show " , " Hide " , " Hearing_4 " , " Hearing_1 " , " Hearing_2 " , " Hearin " , " Alert " , " Explain " ,
" Processing " , " Thinking " , " Searching " , " Acknowledge " };
public static void ChangeRoles( int i_role)
{
MainForm.Character = MainForm.Singleton.axDaControl1.Characters[Roles[i_role]];
}
public static void Hide()
{
MainForm.Character.Hide( null );
}
public static void Show()
{
MainForm.Character.Show( null );
}
public static void Speak( string str)
{
MainForm.Character.Speak(str, null );
}
public static void PlayRandom()
{
Random rdm = new Random(DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Second + DateTime.Now.Minute + DateTime.Now.Millisecond);
int i_rnd = rdm.Next() % Actions.Length;
MainForm.Character.Play(Actions[i_rnd]);
}
public static void SpeakWithAct( string str)
{
Speak(str);
PlayRandom();
}
public static void MoveTo( int x, int y)
{
MainForm.Character.MoveTo(( short )x, ( short )y, null );
}
public static void Move( int x, int y)
{
MainForm.Character.MoveTo(( short )(MainForm.Character.Left + x), ( short )(MainForm.Character.Height + y), null );
}
}
}