Esempio n. 1
0
 private void btnReadCard_Click(object sender, EventArgs e)
 {
     DialogResult dresult = dlgOpen.ShowDialog();
     if (dresult != DialogResult.Cancel)
     {
         System.Threading.Thread.Sleep(0);
         string FileName = dlgOpen.FileName;
         card = vCard.LoadFromFile(FileName);
         if (card != null)
         {
             txtFirstName.Text = card.FullName;
             txtLastName.Text = card.Nickname;
             txtEmail.Text = card.EmailAddresses[0].Address;
             dtBirth.Value = card.Birthday;
         }
     }
 }
Esempio n. 2
0
 private void btnWrite_Click(object sender, EventArgs e)
 {
     if (card == null)
     {
         card = new vCard();
     }
     
     DialogResult dresult = dlgSave.ShowDialog();
     if (dresult != DialogResult.Cancel)
     {
         string FileName = dlgSave.FileName;
         card.FullName = txtFirstName.Text;
         card.Nickname = txtLastName.Text;
         if (card.EmailAddresses.Count == 0)
             card.EmailAddresses.Add(txtEmail.Text, true);
         else
             card.EmailAddresses[0].Address = txtEmail.Text;
         card.Birthday = dtBirth.Value;
         card.SaveToFile(FileName);
     }
 }
Esempio n. 3
0
 public frmvCard()
 {
     InitializeComponent();
     vCard card = new vCard();
     
 }
Esempio n. 4
0
		private static void SetGeo(vCard card, string line)
		{
			GeographicalPosition geo = new GeographicalPosition();
			string val = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
			string[] values = val.Split(';');
			geo.Latitude = System.Convert.ToDecimal(values[0]);
			geo.Longitude = System.Convert.ToDecimal(values[1]);
			card.GeographicalPosition = geo;
		}
Esempio n. 5
0
		private static void SetKey(vCard card, string line)
		{
			card.Key = System.Convert.FromBase64String(line.Replace(line.Split(':')[0]+":",""));
		}
Esempio n. 6
0
		private static void SetCategories(vCard card, string line)
		{
            foreach(string category in Parser.UnescapeArray(line.Replace(line.Split(':')[0]+":","").Split(',')))
			    card.Categories.Add(category);// = Parser.UnescapeArray(line.Replace(line.Split(':')[0]+":","").Split(','));
		}
Esempio n. 7
0
		private static void SetOrganization(vCard card, string line)
		{
            foreach (string organisation in Parser.UnescapeArray(line.Replace(line.Split(':')[0] + ":", "").Split(',')))
                card.Organization.Add(organisation);// = Parser.UnescapeArray(line.Replace(line.Split(':')[0]+":","").Split(','));
		}
Esempio n. 8
0
		private static void SetRevision(vCard card, string line)
		{
			card.Revision = Parser.ParseDate(ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":","")));
		}
Esempio n. 9
0
		private static void AddAddress(vCard card, string line)
		{
			string val = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
			string type = line.Split(':')[0].ToUpper();
			if(type.IndexOf("ENCODING=QUOTED-PRINTABLE")!=-1) val = FromQuotedPrintable(val,"utf-8");
            if (type.IndexOf("ENCODING=B") != -1)
            {
                byte[] data = System.Convert.FromBase64String(val);
                val = System.Text.Encoding.UTF8.GetString(data,0,data.Length);
            }
			string[] values = val.Split(';');
			ActiveUp.Net.Groupware.vCard.Address adr = new ActiveUp.Net.Groupware.vCard.Address();
            if (values.Length > 0 && values[0].Length > 0) adr.POBox = System.Convert.ToInt32(values[0]);
            if (values.Length > 1 && values[1].Length > 0) adr.ExtendedAddress = values[1];
			if (values.Length > 2 && values[2].Length>0) adr.StreetAddress = values[2];
            if (values.Length > 3 && values[3].Length > 0) adr.Locality = values[3];
            if (values.Length > 4 && values[4].Length > 0) adr.Region = values[4];
            if (values.Length > 5 && values[5].Length > 0) adr.PostalCode = values[5];
            if (values.Length > 6 && values[6].Length > 0) adr.Country = values[6];
			string parameters = line.Split(':')[0].ToUpper();
			if(parameters.IndexOf("DOM")!=-1) adr.IsDomestic = true;
			if(parameters.IndexOf("INTL")!=-1) adr.IsInternational = true;
			if(parameters.IndexOf("POSTAL")!=-1) adr.IsPostal = true;
			if(parameters.IndexOf("PARCEL")!=-1) adr.IsParcel = true;
			if(parameters.IndexOf("HOME")!=-1) adr.IsHome = true;
			if(parameters.IndexOf("WORK")!=-1) adr.IsWork = true;
			if(parameters.IndexOf("PREF")!=-1) adr.IsPrefered = true;
			card.Addresses.Add(adr);
		}
Esempio n. 10
0
		private static void SetSortText(vCard card, string line)
		{
			card.SortText = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
		}
Esempio n. 11
0
		private static void SetGeneratorId(vCard card, string line)
		{
			card.GeneratorId = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
		}
Esempio n. 12
0
		private static void SetNickName(vCard card, string line)
		{
			card.Nickname = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
		}
Esempio n. 13
0
		private static void SetName(vCard card, string line)
		{
			string val = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
			string[] values = val.Split(';');
			if(values.Length==0) return;
			if(values.Length>0) card.Name.FamilyName = ActiveUp.Net.Groupware.vCard.Parser.Unescape(values[0]);
			if(values.Length>1) card.Name.GivenName = ActiveUp.Net.Groupware.vCard.Parser.Unescape(values[1]);
			if(values.Length>2) card.Name.AdditionalNames = ActiveUp.Net.Groupware.vCard.Parser.UnescapeArray(values[2].Split(','));
			if(values.Length>3) card.Name.Prefixes = ActiveUp.Net.Groupware.vCard.Parser.UnescapeArray(values[3].Split(','));
			if(values.Length>4) card.Name.Suffixes = ActiveUp.Net.Groupware.vCard.Parser.UnescapeArray(values[4].Split(','));
		}
Esempio n. 14
0
		private static void AddEmail(vCard card, string line)
		{
			string val = line.Split(':')[1];
			ActiveUp.Net.Groupware.vCard.EmailAddress email = new ActiveUp.Net.Groupware.vCard.EmailAddress();
			email.Address = val;
			string parameters = line.Split(':')[0].ToUpper();
			if(parameters.IndexOf("INTERNET")!=-1) email.IsInternet = true;
			if(parameters.IndexOf("X400")!=-1) email.IsX400 = true;
			if(parameters.IndexOf("PREF")!=-1) email.IsPrefered = true;
			card.EmailAddresses.Add(email);
		}
Esempio n. 15
0
		private static void AddLabel(vCard card, string line)
		{
			string val = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
			string type = line.Split(':')[0].ToUpper();
			if(type.IndexOf("ENCODING=QUOTED-PRINTABLE")!=-1) val = FromQuotedPrintable(val,"utf-8");
            if (type.IndexOf("ENCODING=B") != -1)
            {
                byte[] data = System.Convert.FromBase64String(val);
                val = System.Text.Encoding.UTF8.GetString(data,0,data.Length);
            }
			ActiveUp.Net.Groupware.vCard.Label label = new ActiveUp.Net.Groupware.vCard.Label();
			label.Value = val;
			string parameters = line.Split(':')[0].ToUpper();
			if(parameters.IndexOf("DOM")!=-1) label.IsDomestic = true;
			if(parameters.IndexOf("INTL")!=-1) label.IsInternational = true;
			if(parameters.IndexOf("POSTAL")!=-1) label.IsPostal = true;
			if(parameters.IndexOf("PARCEL")!=-1) label.IsParcel = true;
			if(parameters.IndexOf("HOME")!=-1) label.IsHome = true;
			if(parameters.IndexOf("WORK")!=-1) label.IsWork = true;
			if(parameters.IndexOf("PREF")!=-1) label.IsPrefered = true;
			card.Labels.Add(label);
		}
Esempio n. 16
0
		private static void AddTelephoneNumber(vCard card, string line)
		{
			string val = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
			ActiveUp.Net.Groupware.vCard.TelephoneNumber tel = new ActiveUp.Net.Groupware.vCard.TelephoneNumber();
			tel.Number = val;
			string parameters = line.Split(':')[0].ToUpper();
			if(parameters.IndexOf("HOME")!=-1) tel.IsHome = true;
			if(parameters.IndexOf("MSG")!=-1) tel.IsMessage = true;
			if(parameters.IndexOf("WORK")!=-1) tel.IsWork = true;
			if(parameters.IndexOf("VOICE")!=-1) tel.IsVoice = true;
			if(parameters.IndexOf("FAX")!=-1) tel.IsFax = true;
			if(parameters.IndexOf("PREF")!=-1) tel.IsPrefered = true;
			if(parameters.IndexOf("CELL")!=-1) tel.IsCellular = true;
			if(parameters.IndexOf("VIDEO")!=-1) tel.IsVideo = true;
			if(parameters.IndexOf("PAGER")!=-1) tel.IsPager = true;
			if(parameters.IndexOf("BBS")!=-1) tel.IsBulletinBoard = true;
			if(parameters.IndexOf("MODEM")!=-1) tel.IsModem = true;
			if(parameters.IndexOf("CAR")!=-1) tel.IsCar = true;
			if(parameters.IndexOf("ISDN")!=-1) tel.IsISDN = true;
			if(parameters.IndexOf("PCS")!=-1) tel.IsPersonalCommunication = true;
			card.TelephoneNumbers.Add(tel);
		}
Esempio n. 17
0
		private static void SetAccessClass(vCard card, string line)
		{
			card.AccessClass = ActiveUp.Net.Groupware.vCard.Parser.Unescape(line.Replace(line.Split(':')[0]+":",""));
		}
Esempio n. 18
0
        private void saveAsButton_Click(object sender, EventArgs e)
        {
            DialogResult result = this.savevCardDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    vCard card = new vCard();

                    card.Name.GivenName = this.firstNameTextbox.Text;
                    card.Name.FamilyName = this.lastNameTextbox.Text;

                    if (this.companyTextbox.Text != string.Empty)
                        card.Organization.Add(this.companyTextbox.Text);

                    if (this.officePhoneTextbox.Text != string.Empty)
                        card.TelephoneNumbers.Add(this.officePhoneTextbox.Text, TelephoneNumberSingleType.Work);

                    if (this.homePhoneTextbox.Text != string.Empty)
                        card.TelephoneNumbers.Add(this.homePhoneTextbox.Text, TelephoneNumberSingleType.Home);

                    if (this.mobilePhoneTextbox.Text != string.Empty)
                        card.TelephoneNumbers.Add(this.mobilePhoneTextbox.Text, TelephoneNumberSingleType.Cellular);

                    if (this.emailTextbox.Text != string.Empty)
                        card.EmailAddresses.Add(this.emailTextbox.Text);

                    if (this.birthdayDatePicker.Value != DateTime.Now)
                        card.Birthday = this.birthdayDatePicker.Value;

                    if (this.photoPictureBox.Image != null)
                    {
                        Image image = this.photoPictureBox.Image;
                        MemoryStream stream = new MemoryStream();
                        image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        card.Photo = stream.ToArray();
                    }

                    card.SaveToFile(this.savevCardDialog.FileName);

                    MessageBox.Show(string.Format("The file {0} was saved successfully.", Path.GetFileName(this.savevCardDialog.FileName)));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while trying to save the vCard file.");
                }
            }
        }