精灵

有时为了提高客户体验,往往会在程序中增加帮助系统,当年OfficeXP提供了一种叫助手精灵的帮助插件,一个小老头来帮助用户使用Office。现在Win7了,直接使用以往的Ms Agent来开发老头做使用帮助的话,会出现不兼容的情况(即使安装了MS的兼容包,老头也不是透明的,会有粉色的背景。)。当然,也可以选择自己用不规则窗体开发一个精灵老头,只不过种类繁多的魔法动作就难以实现了。不过还好,国外有人已经把Ms Agent修改了为兼容Win7的DoubleAgent。这里给出下载连接:X86版的DoubleAgent

    下载后即可安装,至于那些精灵的文件,网上有很多,MS官网有4种基本精灵的文件:

http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=bd3c4655-79e4-4791-ab9d-abc7bbd133ef&displayLang=en

    另外还有个地址有一些用户个人开发的精灵文件:不过个人看,还是老头顺眼点。

http://www.msagentring.org/chars.aspx

    把DoubleAgent和精灵安装后,就可以在代码中使用了。首先引用DoubleAgent的组件:Double Agent ActiveX Control,拖动出来的实例为axDaControl系列。

    DoubleAgent的使用方法和Ms Agent完全一样,另外安装包中还给了Doc,可以参考。

    另外给出我简单写的一个DoubleAgent使用类的代码。代码中DoubleAgent的加载精灵在MainForm的单件中。

 

DoubleAgent
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 );
        }
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值