/**m* SpringCardApplication/RtdVCard.GetContentEx * * SYNOPSIS * public RtdVCard GetContentEx() * * DESCRIPTION * Constructs a RtdVCard object, using the values of the different fields in the form * and returns this object * **/ public RtdVCard GetContentEx() { RtdVCard nfcVCard = new RtdVCard(); if (image != null) { pic = ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Jpeg); nfcVCard.set_photo(pic); } foreach (Control c in pContact.Controls) { if (c is TextBox) { nfcVCard.set_input_texts(c.Name, c.Text); } } foreach (Control c in pBusiness.Controls) { if (c is TextBox) { nfcVCard.set_input_texts(c.Name, c.Text); } } foreach (Control c in pPrivate.Controls) { if (c is TextBox) { nfcVCard.set_input_texts(c.Name, c.Text); } } return(nfcVCard); }
/**m* SpringCardApplication/RtdVCardControl.SetContent * * SYNOPSIS * public void SetContent(RtdVCard NFCcard) * * DESCRIPTION * Only called by the "public override void SetContent(Ndef ndef)" method, if the ndef is an RtdVCard object. * It prints on the form the content of the RtdVCard object passed as a parameter. * **/ public void SetContent(RtdVCard NFCcard) { ClearContent(); First_name.Text = NFCcard.First_name; Family_name.Text = NFCcard.Family_name; Nickname.Text = NFCcard.Nickname; Business_phone.Text = NFCcard.Business_phone; Home_phone.Text = NFCcard.Home_phone; Pager.Text = NFCcard.Pager; Fax.Text = NFCcard.Fax; Cell_phone.Text = NFCcard.Cell_phone; Email.Text = NFCcard.Email; Email_alternative.Text = NFCcard.Email_alternative; Address1.Text = NFCcard.Address1; Address2.Text = NFCcard.Address2; Town.Text = NFCcard.Town; Region_State.Text = NFCcard.Region_State; Post_Code.Text = NFCcard.Post_Code; Country.Text = NFCcard.Country; Pro_Address1.Text = NFCcard.Pro_Address1; Pro_Address2.Text = NFCcard.Pro_Address2; Pro_Town.Text = NFCcard.Pro_Town; Pro_Region_State.Text = NFCcard.Pro_Region_State; Pro_Post_Code.Text = NFCcard.Pro_Post_Code; Pro_Country.Text = NFCcard.Pro_Country; Title.Text = NFCcard.Title; Role.Text = NFCcard.Role; Company.Text = NFCcard.Company; if (!NFCcard.get_photo().Equals("")) { PictureBox pb = new PictureBox(); Image loadedImage = Base64ToImage(NFCcard.get_photo()); if (loadedImage != null) { /* Re-dimension before the image to go on the screen : 90*90 */ float WidthPercent = (float)loadedImage.Width / 90; float HeigthPercent = (float)loadedImage.Height / 90; float newWidth; float newHeigth; if (WidthPercent < HeigthPercent) { newWidth = loadedImage.Width / HeigthPercent; newHeigth = loadedImage.Height / HeigthPercent; } else { newWidth = loadedImage.Width / WidthPercent; newHeigth = loadedImage.Height / WidthPercent; } Image NewLoadedImage = new Bitmap(loadedImage, new Size((int)newWidth, (int)newHeigth)); pb.Size = new System.Drawing.Size(90, 90); pb.SizeMode = PictureBoxSizeMode.CenterImage; pb.Image = NewLoadedImage; flpPicture.Controls.Clear(); flpPicture.Controls.Add(pb); image = NewLoadedImage; bRemovePicture.Enabled = true; lPSize.Text = NFCcard.get_photo().Length + " bytes"; } } string birth = NFCcard.Birthday; int year = 0; int month = 0; int day = 0; if (birth.Length == 8) { try { /* Format: yyyymmdd */ year = Int32.Parse(birth.Substring(0, 4)); month = Int32.Parse(birth.Substring(4, 2)); day = Int32.Parse(birth.Substring(6, 2)); DateTime dateBirthday = new DateTime(year, month, day); Birthday.Text = dateBirthday.ToShortDateString(); } catch { Birthday.Text = NFCcard.Birthday; } } else if ((birth.Length == 6) && (birth.Substring(0, 2).Equals("--"))) { try { /* Format: --mmdd */ month = Int32.Parse(birth.Substring(2, 2)); day = Int32.Parse(birth.Substring(4, 2)); DateTime dateBirthday = new DateTime(year, month, day); Birthday.Text = dateBirthday.ToShortDateString(); } catch { Birthday.Text = NFCcard.Birthday; } } else { Birthday.Text = NFCcard.Birthday; } }