/// <summary> /// Get all Email addresses /// </summary> /// <returns></returns> public Email[] GetEmailAddresses() { ElementList el = SelectElements(typeof(Email)); int i = 0; Email[] result = new Email[el.Count]; foreach (Email mail in el) { result[i] = mail; i++; } return result; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_save_Click(object sender, EventArgs e) { //if (txt_name.Texts.Trim().Length == 0) //{ // MsgBox.Show(this, "CSS&IM", "名字不能为空!", MessageBoxButtons.OK); // return; //} if (txt_nickname.Texts.Trim().Length == 0) { txt_nickname.Texts = ""; //MsgBox.Show(this, "CSS&IM", "名字不能为空!", MessageBoxButtons.OK); //return; } if (txt_desc.Texts.Trim().Length == 0) { txt_desc.Texts = ""; //MsgBox.Show(this, "CSS&IM", "名字不能为空!", MessageBoxButtons.OK); //return; } //this.tab_state.Text = "数据更新中请等待……!"; SaveVcard = new Vcard(); SaveVcard.SetTag("sex", txt_sex.SelectText);//性别 SaveVcard.Fullname = txt_name.Texts.ToString();//名字 SaveVcard.Nickname = txt_nickname.Texts.ToString();//昵称 SaveVcard.Birthday = txt_bar.Value;//生日 Telephone telephone1 = new Telephone(TelephoneLocation.HOME, TelephoneType.VOICE, txt_phone1.Texts);//电话 SaveVcard.AddTelephoneNumber(telephone1); Telephone telephone2 = new Telephone(TelephoneLocation.HOME, TelephoneType.CELL, txt_phone2.Texts);//手机 SaveVcard.AddTelephoneNumber(telephone2); Email email = new Email(EmailType.HOME, txt_email.Texts, true);//邮箱 SaveVcard.AddEmailAddress(email); Telephone telephone3 = new Telephone(TelephoneLocation.HOME, TelephoneType.FAX, txt_fox.Texts);//传真 SaveVcard.AddTelephoneNumber(telephone3); SaveVcard.Title = txt_job.Texts;//职务 SaveVcard.Description = txt_desc.Texts.ToString();//个人签名 Organization org = new Organization(txt_companyName.Texts, txt_depar.Texts);//公司名称 SaveVcard.Organization = org; Address address1=new Address(AddressLocation.WORK,"",txt_county.Texts,"",txt_province.Texts,txt_postalCode.Texts,txt_companyAddress.Texts,true); SaveVcard.AddAddress(address1); SaveVcard.Url = txt_companyDefault.Texts; Address address2 = new Address(AddressLocation.HOME, "", txt_meMarsk.Texts, "", txt_meDefault.Texts, "", "", true); SaveVcard.AddAddress(address2); Photo po = new Photo(pic_top.Image, ImageFormat.Jpeg); SaveVcard.Photo = po; VcardIq viq = new VcardIq(IqType.set, null, new Jid(XmppConn.MyJID.User), SaveVcard); XmppConn.IqGrabber.SendIq(viq, new IqCB(SaveVcardResult), null); }
/// <summary> /// Adds a new Email Adress object /// </summary> /// <param name="mail"></param> public void AddEmailAddress(Email mail) { Email e = GetEmailAddress(mail.Type); if (e != null) e.Remove(); this.AddChild(mail); }