(C #) SKYPE API Project Summary (i)

Source: Internet
Author: User

Original: (C #) SKYPE API Project Summary (i)

This project needs: Skype software text chat synchronization translation, and will be translated content will be sent to the other side, will be sent to their own words translated into their own language. function See figure:


When you click on the use of the cow, in the Skype software, the above image will pop up, click Allow this plugin will be able to operate on Skype, the interface will become the picture on the right.

Double click online Friends will appear chat dialog box:

The Skype software will also sync if you send it here:

This Skype widget is mainly used by Microsoft online Translator API and Skype API, Microsoft Online Translator reference using the document, Skype API, execute folder in the Reg.bat to register this DLL before use. Skype4COM.dll Reference please refer to the small chapter of the blog, Next I will summarize the small plug-in to use some of the knowledge points.

1. Software interface:

The software interface is used by the commonly used DotNetBar cracked. dll class library.

2. Use of translation interfaces:

The function of translation using the translation interface is made into a webservice, because the translation interface API is used to share a app_id, first in its own WS to refer to the Microsoft Online translator Web_service.


The code is as follows:

 public class WS_Translate:System.Web.Services.WebService {string appId = System.Configuration.ConfigurationM Anager.        appsettings["application_id"]; Servicerefer.languageserviceclient client = new Servicerefer.languageserviceclient ();//Microsoft Online Translator Web service [W Ebmethod (discription= "Get translation results <BR> parameters: String text (the text to be translated), string from (the language code of the text), string to (the target language code to be translated) <br                                            > Return: String (translated text)] public string Gettranslateresult (string text,string from,string to) { String resulte=client.                      Translate (appId, text, from,to, "text/html", "General");        return resulte; } [WebMethod (discription= "Return language code <BR> parameters: None <BR> return: string[]")] public string[] Getlanguagescod E () {string[] Languagescode = client. Getlanguagesfortranslate (APPID); return languagescode; [WebMethod (discription=) returns a list of language names that should be language based on the type of display language provided. <BR> parameter: string localelanguage<br> returns:String[] ")] public string[] GetLanguage () {string[] languagesname = client. Getlanguagenames (AppId, "Zh-chs", Getlanguagescode ());//"Zh-chs" Simplified Chinese return languagesname; }     }

The Skype API tool class code is as follows:

namespace yiniu{//<summary>///Skype Tools//</summary> public class Skypetool {///        lt;summary>///Skype object///</summary> public skype skype {get; set;}            <summary>//Current user///</summary> public user CurrentUser {get {try {return this.}                Skype.currentuser;                } catch {return null; }}}///<summary>///Current user///</summary> Public Profile Cu Rrentuserprofile {get {return this. Skype.currentuserprofile; }}///<summary>///My language type///</summary> public String MyCode {get {return th Is. CurrentUser. Languagecode; }}///<summary>//Online friends//</summary> public usercollection Friends {get {return this. Skype.friends; }}///<summary>///Connection Status///</summary> public tonlinestatus status {get {RET Urn this. Skype.CurrentUser.OnlineStatus;  }}///<summary>//Whether Skype is running///</summary> public bool Isskyperunning {get { return this. Skype.Client.IsRunning; }}///<summary>////</summary> public event _iskypeevents_messagesta when message status changes        Tuseventhandler Messagestatus; <summary>////</summary> public event _iskypeevents_onlinestatuseventha when online user status changes        Ndler Onlinestatus; <summary>//Instantiation WebService///</summary> public translateservice translate = new T        Ranslateservice (Conststrings.translate_webservice_url); <summary>///constructor////</summary> public Skypetool () {this. skype = new Skype ();//Instantiate Skype forLike this. Skype.messagestatus + = new _iskypeevents_messagestatuseventhandler (skype_messagestatus);//This event is triggered when the message is sent and the message is received. Skype.onlinestatus + = new _iskypeevents_onlinestatuseventhandler (skype_onlinestatus);//user Online status change triggers this event}///            Lt;summary>///Return status list///</summary> public DataTable GetStatus () {            DataTable list = new DataTable (); List.            Columns.Add (New DataColumn ("Display", typeof (String))); List.            Columns.Add (New DataColumn ("Value", typeof (String))); for (int i = 0; i < 5; i++) {list. Rows.Add (list. NewRow ()); }//English corresponds to the link status list that is read out with the Skype API.            Rows[0][0] = "online"; List.            Rows[1][0] = "Leave"; List.            Rows[4][0] = "Do Not Disturb"; List.            Rows[2][0] = "stealth"; List.            ROWS[3][0] = "Offline"; List.            ROWS[0][1] = "Online"; List.            ROWS[1][1] = "Away"; List.            ROWS[2][1] = "Invisible"; List. rows[3][1] = "Offline"; List.                                               ROWS[4][1] = "DND";        return list;        }//<summary>//Return friends List//</summary>//<returns></returns>            Public string[,] Getfriends () {string[,] list = new String[skype.friends.count, 3];                for (int i = 0; i < Skype.Friends.Count; i++) {int index = 1; if (Skype.friends[i + 1]. FullName! = "" | | Skype.friends[i + 1]. DisplayName! = "" | | Skype.friends[i + 1]. Handle!= "") {//Get user Online status string status=this. Textsataus (this. Skype.get_user (Skype.friends[i + 1]. Handle.tostring ()). Onlinestatus)).                    ToUpper ();                    if (Status = = "ONLINE") {index = 0; } if (Skype.friends[i + 1]. DisplayName = "") {LIst[i, 0] = skype.friends[i + 1]. Displayname.tostring ();//user Nickname} else {if (Skype.friends[i + 1]. FullName = "") {list[i, 0] = skype.friends[i + 1]. Fullname.tostring (); }//User Nickname else {list[i, 0] = skype.friends[i + 1]. Handle.tostring (); }} list[i, 1] = skype.friends[i + 1]. Handle.tostring ();//user name List[i, 2] = index.                ToString ();//user online Status}} return list;        }///<summary>//Return language list//</summary>//<returns></returns>            Public DataTable Gettolanguage (string code) {DataTable list = new DataTable (); List.            Columns.Add (New DataColumn ("Display", typeof (String))); List.                   Columns.Add (New DataColumn ("Value", typeof (String)));    list<string> languagesname = translate. Getlanguagesname (code);//Call WebService list<string> Languagescode = translate.            Getlanguagescode (); for (int i = 0; i < Languagesname.count; i++) {list. Rows.Add (list.                NewRow ()); List. Rows[i][0] = Languagesname[i].                ToString (); List. ROWS[I][1] = Languagescode[i].            ToString ();;        } return list; }///<summary>///Get a user's language type///</summary>//<param name= "FullName        "></param>///<returns></returns> public string Getuserlanguagecode (string fullname) {return Setmycode (Skype.get_user (fullname).         Languagecode.tostring ());        }///<summary>//initialization language///</summary>//<returns></returns> public string Setmycode (string code) {//in Skype and Translatesope ChineseThe English code does not correspond to need to convert if (code = = "Zh-hans" | | code = = "ZH")//Get Sender.languagecode, Chinese is ch, not divided between simplified and traditional            {code = "Zh-chs";            } if (code = = "Zh-hant") {code = "Zh-cht";        } return code; }///<summary>//<param name= "friend" > Friend's username Handl E</param> Public ichat createichat (string friend) {ichat ichat = Skype.createchatwit            H (Friend);        return ichat; }///<summary>////</summary>//<param name= "PMessage" > Information </pa ram>//<param name= "status" > Information status </param> private void Skype_messagestatus (Chatmessage pmess Age, Tchatmessagestatus Status) {if (the this. Messagestatus = null) {this.            Messagestatus (PMessage, Status);    }        }    <summary>//change user status///</summary>//<param name= "status" > User online status </par am> public void Changestatus (string Status) {this.         Skype.changeuserstatus (Skype.Convert.TextToUserStatus (Status));            }///<summary>//start Skype///</summary> public bool Startskype () { try {if (!this. Skype.Client.IsRunning) {this.                                  Skype.Client.Start (False, True); }//Added to the class for controlling this.                              Skype.attach (5, false);            return true;            } catch {return false; }}///<summary>//user Status change events///</summary>//<param Nam E= "Puser" > Users </param>//<param name= "Status" > FormState </param> public void Skype_onlinestatus (User puser, Tonlinestatus Status) {if (the this. Onlinestatus = null) {this.            Onlinestatus (Puser, Status); }}///<summary>//user online status changed to "online" format///</summary> public Strin G Textsataus (Tonlinestatus Status) {return this.        Skype.Convert.OnlineStatusToText (Status); }    }  }

The framework of the software as a whole here comes out, the following chapters are detailed details of the processing, the software all the code download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.