private void CreateContactForms() { var formId = new Guid(SampleConstants.ContactUsFormId); Dictionary<string, object> localizedProperties = new Dictionary<string, object>(); var result = SampleUtilities.CreateLocalizedForm(formId, SampleConstants.ContactUsFormName, SampleConstants.ContactUsFormTitle, SampleConstants.ContactUsFormSuccessMessage, "en"); if (result) { SampleUtilities.CreateLocalizedForm(new Guid(SampleConstants.ContactUsFormId), string.Empty, SampleConstants.ContactUsFormTitleGerman, SampleConstants.ContactUsFormSuccessMessageGerman, "de"); #region Instructional text FormInstructionalText instructionalText = new FormInstructionalText(); instructionalText.Html = @"Send us a message below and we will get back to you as soon as possible (* denotes required responses in the contact form)"; var controlID = SampleUtilities.AddControlToLocalizedForm(formId, instructionalText, "Body", "Instructional text", "en"); instructionalText.Html = @"Senden Sie uns eine Nachricht aus und wir werden uns umgehend mit Ihnen so bald wie möglich (* kennzeichnet erforderliche Reaktionen in das Kontaktformular)"; localizedProperties.Clear(); localizedProperties.Add("Html", @"Senden Sie uns eine Nachricht aus und wir werden uns umgehend mit Ihnen so bald wie möglich (* kennzeichnet erforderliche Reaktionen in das Kontaktformular)"); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region Main layout LayoutControl mainLayout = new LayoutControl(); List<ColumnDetails> mainLayoutColumns = new List<ColumnDetails>(); ColumnDetails mainLayoutColumn1 = new ColumnDetails() { ColumnSpaces = new ColumnSpaces(0, 15, 0, 0), PlaceholderId = "Left" }; mainLayoutColumns.Add(mainLayoutColumn1); ColumnDetails mainLayoutColumn2 = new ColumnDetails() { ColumnSpaces = new ColumnSpaces(0, 0, 0, 15), PlaceholderId = "Right" }; mainLayoutColumns.Add(mainLayoutColumn2); mainLayout.Layout = SampleUtilities.GenerateLayoutTemplate(mainLayoutColumns, string.Empty); mainLayout.ID = "Main"; SampleUtilities.AddControlToLocalizedForm(formId, mainLayout, "Body", "50% + 50% (custom)", "en"); #endregion #region Name box FormTextBox nameBox = new FormTextBox(); nameBox.Title = "Your Name*"; nameBox.TextBoxSize = FormControlSize.Medium; nameBox.ValidatorDefinition.Required = true; nameBox.ValidatorDefinition.MaxLength = 40; controlID = SampleUtilities.AddControlToLocalizedForm(formId, nameBox, "Main_Left", "Textbox", "en"); localizedProperties.Clear(); localizedProperties.Add("Title", "Ihr Name*"); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region Email box FormTextBox emailBox = new FormTextBox(); emailBox.Title = "Your Email*"; emailBox.TextBoxSize = FormControlSize.Medium; emailBox.ValidatorDefinition.Required = true; emailBox.ValidatorDefinition.MaxLength = 40; controlID = SampleUtilities.AddControlToLocalizedForm(formId, emailBox, "Main_Left", "Textbox", "en"); localizedProperties.Clear(); localizedProperties.Add("Title", "Ihr Email*"); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region Categories list FormDropDownList categoriesList = new FormDropDownList(); categoriesList.Title = "Category"; categoriesList.Choices.Clear(); ChoiceItem athleticsItem = new ChoiceItem() { Text = "Athletics", Value = "Athletics", Description = "Athletics" }; categoriesList.Choices.Add(athleticsItem); ChoiceItem admissionsItem = new ChoiceItem() { Text = "Admissions", Value = "Admissions", Description = "Admissions" }; categoriesList.Choices.Add(admissionsItem); ChoiceItem shopItem = new ChoiceItem() { Text = "Shop", Value = "Shop", Description = "Shop" }; categoriesList.Choices.Add(shopItem); controlID = SampleUtilities.AddControlToLocalizedForm(formId, categoriesList, "Main_Left", "Dropdown list", "en"); athleticsItem.Text = "Sport"; athleticsItem.Description = "Sport"; admissionsItem.Text = "Zulassung"; admissionsItem.Description = "Zulassung"; shopItem.Text = "E-Shop"; shopItem.Description = "E-Shop"; localizedProperties.Clear(); localizedProperties.Add("Title", "Kategorie"); localizedProperties.Add("Choices", categoriesList.Choices); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region Message box FormParagraphTextBox messageBox = new FormParagraphTextBox(); messageBox.Title = "Message*"; messageBox.ParagraphTextBoxSize = FormControlSize.Medium; messageBox.ValidatorDefinition.Required = true; messageBox.ValidatorDefinition.MaxLength = 400; controlID = SampleUtilities.AddControlToLocalizedForm(formId, messageBox, "Main_Left", "Paragraph textbox", "en"); localizedProperties.Clear(); localizedProperties.Add("Title", "Meldung*"); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region SubmitButton FormSubmitButton submitButton = new FormSubmitButton(); submitButton.Text = "Send"; submitButton.ButtonSize = FormControlSize.Small; controlID = SampleUtilities.AddControlToLocalizedForm(formId, submitButton, "Main_Left", "Submit button", "en"); submitButton.Text = "Senden"; localizedProperties.Clear(); localizedProperties.Add("Text", "Senden"); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region Multiple choice FormMultipleChoice genderMultipleChoice = new FormMultipleChoice(); genderMultipleChoice.Title = "Sex"; genderMultipleChoice.Choices.Clear(); ChoiceItem maleItem = new ChoiceItem() { Text = "Male", Value = "Male", Description = "Male" }; genderMultipleChoice.Choices.Add(maleItem); ChoiceItem femaleItem = new ChoiceItem() { Text = "Female", Value = "Female", Description = "Female" }; genderMultipleChoice.Choices.Add(femaleItem); controlID = SampleUtilities.AddControlToLocalizedForm(formId, genderMultipleChoice, "Main_Right", "Multiple choice", "en"); genderMultipleChoice.Title = "Geschlecht"; maleItem.Text = "Männlich"; maleItem.Description = "Männlich"; femaleItem.Text = "Weiblich"; femaleItem.Description = "Weiblich"; localizedProperties.Clear(); localizedProperties.Add("Title", "Geschlecht"); localizedProperties.Add("Choices", genderMultipleChoice.Choices); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion #region Major checkboxes FormCheckboxes majorCheckboxes = new FormCheckboxes(); majorCheckboxes.Title = "What major are you interested in?"; majorCheckboxes.Choices.Clear(); ChoiceItem artHistory = new ChoiceItem() { Text = "Art History", Value = "Art History", Description = "Art History" }; majorCheckboxes.Choices.Add(artHistory); ChoiceItem asianStudies = new ChoiceItem() { Text = "Asian Studies", Value = "Asian Studies", Description = "Asian Studies" }; majorCheckboxes.Choices.Add(asianStudies); ChoiceItem astronomy = new ChoiceItem() { Text = "Astronomy", Value = "Astronomy", Description = "Astronomy" }; majorCheckboxes.Choices.Add(astronomy); ChoiceItem biochemistry = new ChoiceItem() { Text = "Biochemistry and Molecular Biology", Value = "Biochemistry and Molecular Biology", Description = "Biochemistry and Molecular Biology" }; majorCheckboxes.Choices.Add(biochemistry); ChoiceItem biology = new ChoiceItem() { Text = "Biology", Value = "Biology", Description = "Biology" }; majorCheckboxes.Choices.Add(biology); ChoiceItem chemistry = new ChoiceItem() { Text = "Chemistry", Value = "Chemistry", Description = "Chemistry" }; majorCheckboxes.Choices.Add(chemistry); ChoiceItem chinese = new ChoiceItem() { Text = "Chinese", Value = "Chinese", Description = "Chinese" }; majorCheckboxes.Choices.Add(chinese); ChoiceItem classics = new ChoiceItem() { Text = "Classics", Value = "Classics", Description = "Classics" }; majorCheckboxes.Choices.Add(classics); ChoiceItem computerScience = new ChoiceItem() { Text = "Computer Science", Value = "Computer Science", Description = "Computer Science" }; majorCheckboxes.Choices.Add(computerScience); ChoiceItem economics = new ChoiceItem() { Text = "Economics", Value = "Economics", Description = "Economics" }; majorCheckboxes.Choices.Add(economics); controlID = SampleUtilities.AddControlToLocalizedForm(formId, majorCheckboxes, "Main_Right", "Checkboxes", "en"); majorCheckboxes.Title = "Welche Fächer interessieren Sie?"; artHistory.Text = "Kunstgeschichte"; artHistory.Description = "Kunstgeschichte"; asianStudies.Text = "Asiatische Lehren"; asianStudies.Description = "Asiatische Lehren"; astronomy.Text = "Astronomie"; astronomy.Description = "Astronomie"; biology.Text = "Biologie"; biology.Description = "Biologie"; biochemistry.Text = "Biochemie und Molekularbiologie"; biochemistry.Description = "Biochemie und Molekularbiologie"; chinese.Text = "Chinesisch"; chinese.Description = "Chinesisch"; classics.Text = "Klassische Lehren"; classics.Description = "Klassische Lehren"; computerScience.Text = "Informatik"; computerScience.Description = "Informatik"; economics.Text = "Wirtschaft"; economics.Description = "Wirtschaft"; chemistry.Text = "Chemie"; chemistry.Description = "Chemie"; localizedProperties.Clear(); localizedProperties.Add("Title", "Welche Fächer interessieren Sie?"); localizedProperties.Add("Choices", majorCheckboxes.Choices); SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de"); #endregion } }
public FormViewer(Form form) { InitializeComponent(); form.InitSections(); this.form = form; this.Title = form.Name; layout = new StackLayout(); layout.Orientation = StackOrientation.Vertical; foreach (Section section in form.sections) { FormSectionLabel lblSection = new FormSectionLabel(); lblSection.Text = section.text; layout.Children.Add(lblSection); //loop through each child control inside the section foreach (Field field in section.fields) { //create label FormLabel lblText = new FormLabel(field); lblText.Text = field.text; layout.Children.Add(lblText); //create field switch (field.type) { case "text": FormEntry entText = new FormEntry(field, lblText); layout.Children.Add(entText); entText.ClassId = field.id.ToString(); if (field.value != null && !String.IsNullOrWhiteSpace(field.value)) { entText.Text = field.value; } break; case "number": FormEntry entNumber = new FormEntry(field, lblText) { Placeholder = "", Keyboard = Keyboard.Numeric, ClassId = field.id.ToString() }; if (field.value != null && !String.IsNullOrWhiteSpace(field.value)) { entNumber.Text = field.value; } layout.Children.Add(entNumber); break; case "radio": FormDropDownList entPicker = new FormDropDownList(field, lblText) { Title = "Select...", ClassId = field.id.ToString() }; foreach (string pickeritem in field.options) { entPicker.Items.Add(pickeritem); } if (field.value != null && !String.IsNullOrWhiteSpace(field.value)) { entPicker.SelectedIndex = entPicker.Items.IndexOf(entPicker.Items.FirstOrDefault(i => i.ToString() == field.value)); } layout.Children.Add(entPicker); break; case "date": FormDate entDate = new FormDate(field, lblText) { Format = "MMMM dd, yyyy", ClassId = field.id.ToString() }; if (field.value != null && !String.IsNullOrWhiteSpace(field.value)) { entDate.Date = DateTime.Parse(field.value); } layout.Children.Add(entDate); break; case "boolean": FormBoolean entToggle = new FormBoolean(field, lblText) { ClassId = field.id.ToString() }; if (field.value != null && !String.IsNullOrWhiteSpace(field.value)) { entToggle.IsToggled = field.value.Trim().ToLower() == "true"; } layout.Children.Add(entToggle); break; } } } FormContent.Content = layout; // Bind the Help and Complete buttons btnHelp.Clicked += (sender, args) => { DisplayAlert("Help", "You have been alerted", "OK", "Cancel"); }; btnComplete.Clicked += (sender, args) => { // if all fields are complete, set to complete status this.form.status2 = FormStatus.Complete; // Check that all required fields are valid if (AreAllFieldsValid()) { this.form.status2 = FormStatus.Complete; Navigation.PopAsync(); } else { DisplayAlert("Form Invalid", "This form could not be marked as complete because there was invalid data entered", "Ok"); } }; }