|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我见过java运行在手机上,包括很廉价的山寨手机,但是却暂时没发现.net在手机上有什么作为。wp7可能是个转机,但是按照《Java的跨平台就是一句谎言。那.net的跨平台也当之无愧是一句谎言。asp.net|skype|页面ThissampleshowshowtouseSkypefeaturesinyourASP.NET2.0website.BasedupontheSkypeusernameandstandardphonenumber,youtypeintheappropriatefields.SixLinkButtonsarepopulatedwiththestringsthatSkypeneedsinawebsitetodothebasicactions,whichare:
MakeaSkypecallviaSkype.
Requestcontactinformation.
Startachat.
SendafileviaSkype.
Addacontact.
MakeaSkypeOutCall.
Creatingthissample
Istartedthissamplebycreatinganewemptywebsite,selectedtheAddNewItemUnderWebsiteoption,andselectedanewWebUserControltoaddtomyapplicationthatIcalledSkypeSample(itgetsthe.ascxextensionaftercreation).OnthisWebsUserControl,Icreatedthefollowingcontrols:
ALabelwiththeTextpropertySkypeName
ALabelwiththeTextpropertyPhoneNr
ATextBoxwiththeIDtxtSkypeName
ATextBoxwiththeIDtxtPhoneNr
AButtoncalledButton1bydefault,withtheTextpropertysettoPopulate
SixLinkButtonscalled,bydefault,Linkbutton1...
SixstandardtypeImagescalled,bydefault,Image1...
Further,IhaveaddedafolderImagestotheproject,anddownloadedasetofimagesdeveloperscanusefromtheSkypewebsite(Clickheretodownloadtheimages),andchosenthebuttonsIneeded,andaddedthemtothecreatedimagemap.IsetthepathofmycontrolsImage1toImage6totheappropriateimageinmyImagesfolder.
ForButton1,IcreatedaneventcalledPopulate_Click,andthefollowingcodethatwillfirethemethodSetSkypeStatusthatIcreatedlateron.
//GetSpypeStatus
try
{
this.SetSkype();
}
catch
{
//
}
finally
{
//
}
ThenIclickedontheUserControltogotothecode-behind,andcreatedamethodcalledSetSkypeandtheneededstringsfortheapplication.
protectedvoidSetSkype()
{
//SettheImagesonthewebsitetounvisible
Image1.Visible=true;
Image2.Visible=true;
Image3.Visible=true;
Image4.Visible=true;
Image5.Visible=true;
Image6.Visible=true;
//CreatetheStringsthatwillhold
//theneededvaluesandactions
stringSkypeName=txtSkypeName.Text;
stringLandPhone=txtPhoneNr.Text;
stringPathSkypeStatusString="";
stringSkypeAddContactString="";
stringSkypeCallString="";
stringSkypeLandCall="";
stringSkypeChattString="";
stringSkypeProfileString="";
stringSkypeSendFileString="";
Topopulatethestringswithvalues,Icreatedtryblocks.ThefirstblockgetsthestatusoftheSkypeusernamethatistypedinafterthemethodisfired.Asyoucanseeinthecodebelow,Icreatedthreestrings(s1,s2,sT);thelastoneofthethreeinthefirsttryblockstandsforthestringtotalsinceItriedtocreateastringIcanusetogetthestatusoftheSkypecontact.Asyoucanseebelow,thefirstpartofthestringisaURLthatsayswheretolook,andwhaticontouse.Youcouldchangetheword"mediumicon"to,forexample,"largeicon",andalargeiconwillbeshown.ThestringsT=partinthisblocksetstheactualvalueofthestringsTtothestringIwant,thepathtolookplustheSkypeusernameIwantthestatusof.ThevaluesTholdsisthenpassedtotheabovecreatedPathSkypeStatusString;andIassignPathSkypeStatusStringasthevalueoftheImage1URL,soatruntime,thisimageshouldshowamediumiconwiththecurrentstatusoftheuser.
//GetSpypeStatus
try
{
strings1="http://mystatus.skype.com/mediumicon/";
strings2=SkypeName;
stringsT=s1+s2;
PathSkypeStatusString=sT;
Image1.ImageUrl=PathSkypeStatusString;
}
catch
{
//
}
finally
{
//
}
Inthenextpart,IneedmorestringsbecausetheSkypeusernamewillbeinthemiddleofthestring,socreatingthecompletestringisalittlemorecomplicated.s4isimportantinthispartbecausethatistheactionthatwillbeperformedatruntime,ands6inthetextthatwillbevisibleintheLinkButton.Again,IcreatethestringsT,passthevaluetoSkypeCallString,andsetthevalueofLinkButton1tothecontentofSkypeCallString,soatruntime,thisLinkbuttonwillinitiatethecallwhenclicked.Inthecode,theHREFvalueisseenwithnoclosingtagbecausethatoneislateraddedwhenIsetthevalueofthestrings6.
//SetCallString
try
{
//strings1="seecode";
strings2="skype:";
strings3=SkypeName;
strings4="?call";
strings5=".ToString();
strings6=">SkypeMe";
stringsT=s1+s2+s3+s4+s5+s6;
SkypeCallString=sT;
LinkButton1.Text=SkypeCallString;
}
catch
{
//Todo
}
finally
{
//Todo
}
Irepeatthisforalltheactionsthatcanbeperformedbytheuser,settingthevaluesoftheLinkButtonstotheactionsIwantthemtoperform.Itsclearwhythedifferentactionsalwayslooklike?call,?chatetc.
Runningthesamplecode
Torunthesamplecode,youjustopentheSkypeSamplefolderwithVisualStudio,underthemenuoptionFile,Open,andtheselectthewebsite.Thecodeshouldbeloaded,andwhenyouhitF5,thesampleapplicationshouldrun.
Furtheruse
ThissampleiseasytousedynamicallywhenyoustoretheSkypeusernameandphonenumberinadatabaseandpresentthesevaluesinyourwebsite,with,forexample,aDetailControlthatyouloadwithadatasource.WhenyousettheSkypeusernameandphonenumberasDataKeysfortheDetailControl,youcanusethevaluestheyholdatruntimeforpopulatingthestrings(Skypeusernameandphonenumber).BelowisasamplethatshowshowyoucouldsetthepropertiesfromSkype.
//SetSkypeNameandSkypeLandCallstringvaluesdynamically
try
{
//SetStringSkypeName
stringSkypeName=DetailsView1.DataKey["Skype"].ToString();
//SetstringSkypeLandCall
stringSkypeLandCall=DetailsView1.DataKey["CompanyPhone"].ToString();
}
catch
{
//Todo
}
finally
{
//Todo
}
PointsofInterest
Iamnotsayingthatthecodeisperfectbutitworkswellfrommylaptop.WhenIrequestthewebsitefrommylocalserver,allSkypeoptionswork.ThenameSkypeiscopyrightofSkypeLimited.
呵呵,那你就关注微软的招聘信息以及别人的招聘经验啊,还有也不一定去做技术的,你如果真的想去就多了解了解。(其实我的意思是说想到微软做技术是很不容易的。 |
|