/// <inheritDocs/> public void Configure(ref FieldControl backendControl, IFormFieldController <IFormFieldModel> formFieldController) { var checkboxesFieldModel = (ICheckboxesFieldModel)formFieldController.Model; if (checkboxesFieldModel.HasOtherChoice) { backendControl = new FormTextBox(); backendControl.ValidatorDefinition = checkboxesFieldModel.ValidatorDefinition; backendControl.Title = checkboxesFieldModel.MetaField.Title; ((IFormFieldControl)backendControl).MetaField = checkboxesFieldModel.MetaField; } else { var choices = checkboxesFieldModel.DeserializeChoices(); var checkboxesControl = (FormCheckboxes)backendControl; checkboxesControl.Choices.Clear(); foreach (var choice in choices) { checkboxesControl.Choices.Add(new Web.UI.Fields.ChoiceItem() { Text = choice, Value = choice }); } } }
private void FormTextBox_LostFocus(object sender, EventArgs e) { try { FormattedValue = FormTextBox.Text; } catch (FormatException) { TaskDialog.Show("Invalid Unit Format", "Could not understand input value. Please try again."); FormTextBox.SelectAll(); } }
protected override Control CreateControl() { return(Defaults.Container .With(_formatControl = new FormSimpleDropdown("Формат", _formatValues)) .With(Defaults.Margin(10)) .With(_qualityControl = new FormSimpleDropdown("Качество", _qualityValues)) .With(Defaults.Margin(10)) .With(_companyControl = new FormSimpleDropdown("Компания", _companyValues)) .With(Defaults.Margin(10)) .With(_durationControl = new SearchFormControl <TimeSpan>(new FormDurationPicker("Продолжительность"))) .With(Defaults.Margin(10)) .With(_genreControl = new FormSimpleDropdown("Жанр", _genreValues)) .With(Defaults.Margin(10)) .With(_releaseDateControl = new SearchFormControl <DateTime>(new FormDatePicker("Дата выхода"))) .With(Defaults.Margin(10)) .With(_nameControl = new FormTextBox("Название"))); }
protected override void AddRules(List <FormRule> rules) { rules.Add((isPostBack, formItem, argument) => { FormSelect selCity = GetItem <FormSelect>("City"); FormSelect selMunicipality = GetItem <FormSelect>("MunicipalitySelect"); FormTextBox txtMunicipality = GetItem <FormTextBox>("MunicipalityTextBox"); selMunicipality.Hidden = true; txtMunicipality.Hidden = true; if (!selCity.Value.Any()) { return; } long cityId = Convert.ToInt64(selCity.Value.Single().Value); tblMunicipality[] municipalities = tblMunicipality.ListForcityId(cityId).ToArray(); if (municipalities.Length == 0) { txtMunicipality.Hidden = false; return; } selMunicipality.Hidden = false; FormOption prevMunicipality = selMunicipality.Value.SingleOrDefault(); selMunicipality.Content = municipalities.Select(m => new FormOption((int)m.id, m.name)); if (prevMunicipality == null) { return; } foreach (var o in selMunicipality.Content) { o.IsSelected = o.Equals(prevMunicipality); } }); }
private List<AbstractFormElement> MapValueExpressions(List<string> valueExpressions) { if (valueExpressions != null && valueExpressions.Count > 0) { List<AbstractFormElement> valueElements = new List<AbstractFormElement>(); foreach (var item in valueExpressions) { Regex blockRx = new Regex("{{block:(.*?)}}"); Regex dateRx = new Regex("{{date:(.*?)}}"); if (blockRx.Match(item).Success) { FormTextBlock textBlock = new FormTextBlock(); textBlock.Name = item.Replace("{{block:", string.Empty).Replace("}}", string.Empty); textBlock.Expression = item; textBlock.Text = string.Empty; valueElements.Add(textBlock); } else if (dateRx.Match(item).Success) { FormDate date = new FormDate(); date.Name = item.Replace("{{date:", string.Empty).Replace("}}", string.Empty); ; date.Expression = item; date.Date = DateTime.Now; valueElements.Add(date); } else { FormTextBox textBox = new FormTextBox(); textBox.Name = item.Replace("{{", string.Empty).Replace("}}", string.Empty); textBox.Expression = item; textBox.Text = string.Empty; valueElements.Add(textBox); } } return valueElements; } return null; }
/// <inheritDocs/> public void Configure(ref FieldControl backendControl, IFormFieldController<IFormFieldModel> formFieldController) { var checkboxesFieldModel = (ICheckboxesFieldModel)formFieldController.Model; if (checkboxesFieldModel.HasOtherChoice) { backendControl = new FormTextBox(); backendControl.ValidatorDefinition = checkboxesFieldModel.ValidatorDefinition; backendControl.Title = checkboxesFieldModel.MetaField.Title; ((IFormFieldControl)backendControl).MetaField = checkboxesFieldModel.MetaField; } else { var choices = checkboxesFieldModel.DeserializeChoices(); var checkboxesControl = (FormCheckboxes)backendControl; checkboxesControl.Choices.Clear(); foreach (var choice in choices) { checkboxesControl.Choices.Add(new Web.UI.Fields.ChoiceItem() { Text = choice, Value = choice }); } } }
private void addToolStripMenuItem_Click(object sender, EventArgs e) { FormTextBox form = new FormTextBox(); form.labelInput.Text = "Input name:"; form.Text = "Names.BIN: New Entry"; if (form.ShowDialog() == DialogResult.OK) { NamesBINEntry entry = myNames.AddEntry(form.textBoxInput.Text); ListViewItem item = new ListViewItem(); item.Text = entry.Name; item.SubItems.Add(entry.Enum.ToString()); item.SubItems.Add(entry.Offset.ToString()); listViewEntries.Items.Add(item); listViewEntries.Sort(); } }
public virtual void Visit(FormTextBox formTextBox, HtmlContainer htmlContainer) { if (formTextBox.Icon == FormIcon.NotSet) { return; } HtmlTextBox htmlTextBox = null; int i; for (i = 0; i < htmlContainer.Contents.Count; i++) { if (htmlContainer.Contents[i] is HtmlTextBox) { htmlTextBox = (HtmlTextBox)htmlContainer.Contents[i]; break; } } if (htmlTextBox == null) { return; } htmlContainer.Remove(htmlTextBox); HtmlItalic htmlItalic = new HtmlItalic(); htmlItalic.Class.AddRange(IconClass(formTextBox.Icon)); HtmlDiv htmlDiv = new HtmlDiv(); htmlDiv.Add(htmlTextBox); htmlDiv.Insert(prepend ? 0 : 1, htmlItalic); htmlContainer.Insert(i, htmlDiv); }
public List <UIElement> BuildUIElements(List <AbstractFormElement> list) { Thickness defaultMargin = new Thickness(20, 5, 20, 5); List <UIElement> uiList = new List <UIElement>(); foreach (var item in list) { if (item is FormCheckBox) { FormCheckBox formCheckBox = item as FormCheckBox; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(1.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); CheckBox checkBox = new CheckBox(); checkBox.Margin = defaultMargin; Binding isChecked = new Binding("IsChecked"); isChecked.Source = formCheckBox; isChecked.Mode = BindingMode.TwoWay; checkBox.SetBinding(CheckBox.IsCheckedProperty, isChecked); TextBlock textBlock = new TextBlock(); textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Text = formCheckBox.Text; checkBox.Content = textBlock; Grid.SetColumnSpan(checkBox, 2); grid.Children.Add(checkBox); uiList.Add(grid); } if (item is FormDropDown) { FormDropDown formDropDown = item as FormDropDown; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(2.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; TextBlock textBlock = new TextBlock(); textBlock.Margin = defaultMargin; textBlock.FontWeight = FontWeights.Bold; Binding text = new Binding("Name"); text.Source = formDropDown; text.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, text); ComboBox comboBox = new ComboBox(); comboBox.Margin = defaultMargin; Binding options = new Binding("Options"); options.Source = formDropDown; options.Mode = BindingMode.TwoWay; comboBox.SetBinding(ComboBox.ItemsSourceProperty, options); Binding selectedIndex = new Binding("SelectedIndex"); selectedIndex.Source = formDropDown; selectedIndex.Mode = BindingMode.TwoWay; comboBox.SetBinding(ComboBox.SelectedIndexProperty, selectedIndex); Binding selectedValue = new Binding("SelectedValue"); selectedValue.Source = formDropDown; selectedValue.Mode = BindingMode.OneWay; comboBox.SetBinding(ComboBox.SelectedValueProperty, selectedValue); Grid.SetColumn(textBlock, 0); Grid.SetColumn(comboBox, 1); grid.Children.Add(textBlock); grid.Children.Add(comboBox); uiList.Add(grid); } if (item is FormRadioButton) { FormRadioButton formRadioButton = item as FormRadioButton; StackPanel stackPanel = new StackPanel(); stackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; stackPanel.VerticalAlignment = VerticalAlignment.Stretch; for (int i = 0; i < formRadioButton.Options.Count; i++) { TextBlock textBlock = new TextBlock(); textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Text = formRadioButton.Options[i]; RadioButton radioButton = new RadioButton(); radioButton.Margin = defaultMargin; radioButton.Content = textBlock; radioButton.GroupName = item.Name; radioButton.Checked += (sender, args) => { formRadioButton.SelectedIndex = formRadioButton.Options.IndexOf(textBlock.Text); }; if (i == formRadioButton.SelectedIndex) { radioButton.IsChecked = true; } RowDefinition rowDefinition = new RowDefinition(); stackPanel.Children.Add(radioButton); } GroupBox groupBox = new GroupBox(); groupBox.Header = item.Name; groupBox.Content = stackPanel; groupBox.Margin = defaultMargin; uiList.Add(groupBox); } if (item is FormTextBox) { FormTextBox formTextBox = item as FormTextBox; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(2.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.Bold; textBlock.Margin = defaultMargin; Binding label = new Binding("Name"); label.Source = formTextBox; label.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, label); TextBox textBox = new TextBox(); textBox.Margin = defaultMargin; Binding text = new Binding("Text"); text.Source = formTextBox; text.Mode = BindingMode.TwoWay; text.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBox.SetBinding(TextBox.TextProperty, text); textBox.Text = item.Name; Grid.SetColumn(textBlock, 0); Grid.SetColumn(textBox, 1); grid.Children.Add(textBlock); grid.Children.Add(textBox); uiList.Add(grid); } if (item is FormTextBlock) { FormTextBlock formTextBlock = item as FormTextBlock; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; stackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; stackPanel.VerticalAlignment = VerticalAlignment.Stretch; stackPanel.Margin = defaultMargin; TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.Bold; textBlock.TextWrapping = TextWrapping.Wrap; Binding label = new Binding("Name"); label.Source = formTextBlock; label.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, label); TextBox textBox = new TextBox(); textBox.MinLines = 5; textBox.AcceptsReturn = true; textBox.AcceptsTab = true; textBox.TextWrapping = TextWrapping.Wrap; Binding text = new Binding("Text"); text.Source = formTextBlock; text.Mode = BindingMode.TwoWay; text.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBox.SetBinding(TextBox.TextProperty, text); textBox.Text = item.Name; stackPanel.Children.Add(textBlock); stackPanel.Children.Add(textBox); uiList.Add(stackPanel); } if (item is FormDate) { FormDate formDate = item as FormDate; Grid grid = new Grid(); ColumnDefinition columnDefinition1 = new ColumnDefinition(); columnDefinition1.Width = new GridLength(1.0, GridUnitType.Star); ColumnDefinition columnDefinition2 = new ColumnDefinition(); columnDefinition2.Width = new GridLength(2.0, GridUnitType.Star); grid.ColumnDefinitions.Add(columnDefinition1); grid.ColumnDefinitions.Add(columnDefinition2); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.Bold; textBlock.Margin = defaultMargin; textBlock.TextWrapping = TextWrapping.Wrap; Binding label = new Binding("Name"); label.Source = formDate; label.Mode = BindingMode.OneWay; textBlock.SetBinding(TextBlock.TextProperty, label); DatePicker datePicker = new DatePicker(); datePicker.Margin = defaultMargin; Binding date = new Binding("Date"); date.Source = formDate; date.Mode = BindingMode.TwoWay; date.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; datePicker.SetBinding(DatePicker.SelectedDateProperty, date); Grid.SetColumn(textBlock, 0); Grid.SetColumn(datePicker, 1); grid.Children.Add(textBlock); grid.Children.Add(datePicker); uiList.Add(grid); } } return(uiList); }
public virtual void Visit(FormTextBox formTextBox, HtmlContainer htmlContainer) { HtmlFieldset htmlFieldset = verbose ? new HtmlFieldset(formTextBox.Path) : new HtmlFieldset(); htmlFieldset.Class.Add("formTextBox"); if (!string.IsNullOrWhiteSpace(formTextBox.CssClass)) { htmlFieldset.Class.AddRange(formTextBox.CssClass.Split(' ').Where(s => s != string.Empty)); } htmlFieldset.Class.Add("form-group"); if (!string.IsNullOrWhiteSpace(formTextBox.Path)) { htmlFieldset.Class.Add(string.Format("{0}{1}", "formId", formTextBox.Path)); } htmlFieldset.Class.Add("formField"); if (initialize) { htmlFieldset.Class.Add(formTextBox.IsRequired ? "formRequired" : "formOptional"); } else { if (formTextBox.HasValue) { htmlFieldset.Class.Add(formTextBox.IsValid ? "formValid" : "formInvalid"); } else { htmlFieldset.Class.Add(formTextBox.IsRequired ? "formNotEntered" : "formOptional"); } } htmlFieldset.Hidden.Value = formTextBox.IsHidden; htmlContainer.Add(htmlFieldset); HtmlTextBox htmlTextBox = new HtmlTextBox(formTextBox.Path); htmlTextBox.Class.Add("form-control"); htmlTextBox.Disabled.Value = formTextBox.IsDisabled; htmlTextBox.ReadOnly.Value = formTextBox.IsReadOnly; htmlTextBox.Value.Value = formTextBox.Value; string placeholder = null; if (!string.IsNullOrWhiteSpace(formTextBox.Placeholder)) { if (formTextBox.IsRequired && formTextBox.IsRequiredInPlaceholder && !string.IsNullOrWhiteSpace(formTextBox.RequiredMark)) { placeholder = string.Format("{0} {1}", formTextBox.Placeholder, formTextBox.RequiredMark); } else if (!formTextBox.IsRequired && formTextBox.IsOptionalInPlaceholder && !string.IsNullOrWhiteSpace(formTextBox.OptionalMark)) { placeholder = string.Format("{0} {1}", formTextBox.Placeholder, formTextBox.OptionalMark); } else { placeholder = formTextBox.Placeholder; } } htmlTextBox.Placeholder.Value = placeholder; if (!initialize && firstInvalidId == null) { if (formTextBox.IsRequired && !formTextBox.HasValue || !formTextBox.IsValid) { firstInvalidId = htmlTextBox.Id.Value; } } switch (formTextBox.OrderElements) { case OrderElements.LabelMarkInput: AddLabelMark(formTextBox, htmlTextBox, htmlFieldset); htmlFieldset.Add(htmlTextBox); break; case OrderElements.MarkLabelInput: AddMarkLabel(formTextBox, htmlTextBox, htmlFieldset); htmlFieldset.Add(htmlTextBox); break; case OrderElements.InputLabelMark: htmlFieldset.Add(htmlTextBox); AddLabelMark(formTextBox, htmlTextBox, htmlFieldset); break; case OrderElements.InputMarkLabel: htmlFieldset.Add(htmlTextBox); AddMarkLabel(formTextBox, htmlTextBox, htmlFieldset); break; case OrderElements.LabelInputMark: AddLabel(formTextBox, htmlTextBox, htmlFieldset); htmlFieldset.Add(htmlTextBox); AddMark(formTextBox, htmlTextBox, htmlFieldset); break; case OrderElements.MarkInputLabel: AddMark(formTextBox, htmlTextBox, htmlFieldset); htmlFieldset.Add(htmlTextBox); AddLabel(formTextBox, htmlTextBox, htmlFieldset); break; default: case OrderElements.NotSet: break; } if (initialize) { return; } string message = null; if (formTextBox.UseLastMessage) { if (!string.IsNullOrEmpty(formTextBox.LastMessage)) { message = formTextBox.LastMessage; } } else if (formTextBox.IsRequired && !formTextBox.HasValue) { message = formTextBox.RequiredMessage; } else if (!formTextBox.IsValid) { message = formTextBox.ValidationMessage; } if (message == null) { return; } HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formTextBox.Path, "Message") : ""); htmlLabelMessage.Class.Add("formValidationMessage"); htmlLabelMessage.For.Value = htmlTextBox.Id.Value; htmlLabelMessage.Add(new HtmlText(message)); htmlFieldset.Add(htmlLabelMessage); }
protected override AssetEntry CreateEntry(BIGBank bank) { FormOpenTexture form = new FormOpenTexture(); AssetEntry entry = null; if (form.ShowDialog(this) == DialogResult.OK) { GfxTexture texture; try { texture = new GfxTexture(form.FileName, form.Format); } catch (Exception ex) { FormMain.Instance.ErrorMessage(ex.Message); return(null); } string name = Path.GetFileNameWithoutExtension(form.FileName); name.Replace(' ', '_'); name.Replace('-', '_'); name.Replace('.', '_'); name = name.ToUpper(); FormTextBox textForm = new FormTextBox(); textForm.Text = "New Texture"; textForm.labelInput.Text = "Texture Symbol Name:"; while (true) { textForm.textBoxInput.Text = name; if (textForm.ShowDialog() == DialogResult.OK) { if (bank.FindEntryBySymbolName( textForm.textBoxInput.Text) != null) { FormMain.Instance.ErrorMessage( "Symbol already exists. Try again."); } else { name = textForm.textBoxInput.Text; break; } } } textForm.Dispose(); entry = new AssetEntry( name, bank.GetNewID(), 0, bank); texture.ApplyToEntry(entry); } form.Dispose(); return(entry); }
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 } }
protected override void CreateForm() { OpenGroup("Container"); #region Defaults OrderElements = OrderElements.LabelMarkInput; Required = true; RequiredMessage = resFieldRequired; #endregion #region Title AddItem(new FormTitle("Title") { Content = resStudents, }); #endregion #region DateOfBirth AddItem(dtpDateOfBirth = new FormDatePicker("DateOfBirth", "dd/mm/yyyy") { Label = resDateOfBirth, Placeholder = resDateOfBirth, Validator = (v) => { if (v > DateTime.Now) { return(resDateInvalid); } return(null); } }); #endregion #region Population AddItem(selPopulation = new FormSelect("Population", false) { Label = resCity, Header = new FormOption(resChoose), Content = tblPopulation.ListAll().Select(p => new FormOption(p.id, p.descr)) }); #endregion #region City AddItem(selCity = new FormSelect("City", false) { Label = resAreaOfResidence, Header = new FormOption(resChoose), Update = true, Content = tblCity.ListAll().OrderBy(c => c.name).Select(c => new FormOption(c.id, c.name)) }); #endregion #region Municipality AddItem(selMunicipality = new FormSelect("MunicipalitySelect", false) { Label = resMunicipality, Header = new FormOption(resChoose), Hidden = true, }); AddItem(txtMunicipality = new FormTextBox("MunicipalityTextBox") { Label = resMunicipality, Hidden = true, }); #endregion #region Email AddItem(txtEmail = new FormTextBox("Email") { Label = resEmail.ToLower(), Validator = (v) => { if (!new Regex(@"^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]*$").IsMatch(v.Trim())) { return(resEmailInvalid); } return(null); }, }); #endregion #region EducationalStage AddItem(selEducationalStage = new FormSelect("EducationalStage", false) { Label = resEducationalStage, Header = new FormOption(resChoose), Update = true, Content = tblEducationalStage.ListAll().Select(s => new FormOption(s.id, s.name)) }); #endregion #region EducationalGrade AddItem(selEducationalGrade = new FormSelect("EducationalGrade", false) { Label = resEducationalGrade, Header = new FormOption(resChoose), Hidden = true, Update = true, }); #endregion #region OrientationGroup AddItem(selOrientationGroup = new FormSelect("OrientationGroup", false) { Label = resOrientationGroup, Header = new FormOption(resChoose), Hidden = true, Content = tblOrientationGroup.ListAll().Select(o => new FormOption(o.id, o.name)) }); #endregion #region CoachingSchool AddItem(txtCoachingSchool = new FormTextBox("CoachingSchool") { Label = resCoachingSchool, Required = false, }); #endregion #region PrivateLessons AddItem(rdgPrivateLessons = new FormRadioGroup("PrivateLessons") { Label = resPrivateLessons, Required = false, Content = new FormRadioButton[] { new FormRadioButton(0, resYes) { IsSelected = false }, new FormRadioButton(1, resNo) { IsSelected = false }, } }); #endregion AddItem(new FormNumberSpinner("NumberSpinner") { Label = "Number", OrderNumberSpinner = OrderNumberSpinner.DecrIncrNumber, Content = "0", DirectInput = false, Min = 0, }); #region Submit AddItem(new FormButton("Submit") { Content = resSend, Submit = true }); #endregion CloseGroup("Container"); }
/// <summary> /// Method that builds and sends confirmation messages to the administrator and, /// if <see cref="SendClientConfirmation"/> is true, the client too. /// </summary> private void SendSubmittedFormDataEmail() { StringBuilder formDataBuilder = new StringBuilder(); StringBuilder formDataHTMLBuilder = new StringBuilder(); List <Attachment> attachments = new List <Attachment>(); foreach (var fieldControl in this.FieldControls) { if (fieldControl is FormCheckboxes) { StringBuilder choicesString = new StringBuilder(); var choices = ((List <String>)((FormCheckboxes)fieldControl).Value).ToList(); for (int i = 0; i < choices.Count(); i++) { choicesString.Append(choices[i]); if (i != choices.Count() - 1) { choicesString.Append(", "); } } formDataBuilder.Append(String.Format("{0}: {1}\r\n", ((FormCheckboxes)fieldControl).Title, choicesString.ToString())); formDataHTMLBuilder.Append(String.Format("{0}: {1}<br/>", ((FormCheckboxes)fieldControl).Title, choicesString.ToString())); } else if (fieldControl is FieldControl) { var control = fieldControl as FieldControl; if (MailUploadedFilesAsAttachments && control.Value.GetType().Equals(typeof(Telerik.Web.UI.UploadedFileCollection))) { Telerik.Web.UI.UploadedFileCollection uploadedFileCollection = (Telerik.Web.UI.UploadedFileCollection)control.Value; attachments.AddRange(FormHandlerMail.CreateFormHandlerMailAttachments(uploadedFileCollection)); } else if (fieldControl.GetType() != typeof(FormCaptcha)) { formDataBuilder.Append(String.Format("{0}: {1}\r\n", control.Title, control.Value)); formDataHTMLBuilder.Append(String.Format("{0}: {1}<br/>", control.Title, control.Value)); } } } // Try get client e-mailaddress if (!String.IsNullOrWhiteSpace(this.ClientConfirmationEmailAddressFormControlName)) { FormTextBox emailFormControl = this.FieldControls.OfType <FormTextBox>().Where(f => f.MetaField.FieldName == this.ClientConfirmationEmailAddressFormControlName).FirstOrDefault(); if (emailFormControl != null) { clientEmailAddress = emailFormControl.Value.ToString(); } } // Try get client ClientConfirmationControl if (!String.IsNullOrWhiteSpace(this.ClientConfirmationControlName) && !String.IsNullOrWhiteSpace(this.clientConfirmationControlSendOptionValue) && SendClientConfirmation) { FieldControl clientConfirmationControlName = this.FieldControls.OfType <FieldControl>().Where(f => f.DataFieldName == this.ClientConfirmationControlName).FirstOrDefault(); if (clientConfirmationControlName != null) { SendClientConfirmation = false; if (clientConfirmationControlName is FormCheckboxes) { var choices = ((List <String>)((FormCheckboxes)clientConfirmationControlName).Value).ToList(); foreach (var selectedChoices in choices) { if (selectedChoices.ToUpper().Equals(clientConfirmationControlSendOptionValue.ToUpper())) { SendClientConfirmation = true; break; } } } else if (clientConfirmationControlName is FormMultipleChoice) { if (clientConfirmationControlSendOptionValue.ToUpper().Equals(clientConfirmationControlName.Value.ToString().ToUpper())) { SendClientConfirmation = true; } } } } #region Administrator mail string bodyText = string.Empty; if (!string.IsNullOrWhiteSpace(emailBody)) { bodyText = emailBody.Replace(SUBMITTED_FORM_DATA_STRING_TAG, formDataBuilder.ToString()); } string bodyHTMLText = string.Empty; if (!string.IsNullOrWhiteSpace(emailBodyHTML)) { bodyHTMLText = emailBodyHTML.Replace(SUBMITTED_FORM_DATA_STRING_TAG, formDataHTMLBuilder.ToString()); } string actualReferrerUrlSessionKey = !String.IsNullOrWhiteSpace(ReferrerUrlSessionKey) ? ReferrerUrlSessionKey : "REFERRER_URL"; string referrerUrl = String.Empty; if (HttpContext.Current.Session[actualReferrerUrlSessionKey] != null) { referrerUrl = ((Uri)HttpContext.Current.Session[actualReferrerUrlSessionKey]).ToString(); } bodyHTMLText = bodyHTMLText.Replace(REFERRER_URL_TAG, referrerUrl); string fromEmailAddressToUse = !String.IsNullOrWhiteSpace(clientEmailAddress) && IsClientEmailAddressUsedAsFromEmailAddress ? clientEmailAddress : fromEmailAddress; FormHandlerMail.SendFormHandlerEmailMessage(fromEmailAddressToUse, ToEmailAddresses, ccEmailAddresses, emailSubject, bodyText, bodyHTMLText, attachments, this.FormName); #endregion #region Client confirmation if (SendClientConfirmation && !String.IsNullOrWhiteSpace(clientEmailAddress)) { string clientBodyText = string.Empty; if (!string.IsNullOrWhiteSpace(clientEmailBody)) { clientBodyText = clientEmailBody.Replace(SUBMITTED_FORM_DATA_STRING_TAG, formDataBuilder.ToString()); } string clientBodyHTMLText = string.Empty; if (!string.IsNullOrWhiteSpace(clientEmailBodyHTML)) { clientBodyHTMLText = clientEmailBodyHTML.Replace(SUBMITTED_FORM_DATA_STRING_TAG, formDataHTMLBuilder.ToString()); } FormHandlerMail.SendFormHandlerEmailMessage(clientFromEmailAddress, clientEmailAddress, clientCcEmailAddresses, clientEmailSubject, clientBodyText, clientBodyHTMLText, null, this.FormName); } #endregion }
public virtual void Visit(FormTextBox formTextBox) { sb.AppendLine(string.Format("{0}{1}: {2}", formTextBox.Label, Mark(formTextBox), formTextBox.Value)); }
protected override Control CreateControl() { return(Defaults.Container .With(_nameControl = new FormTextBox("Название"))); }
public virtual void Visit(FormTextBox formTextBox) { formTextBox.Content = values[formTextBox.Path]; }
protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container) { base.InitializeControls(container); //Injects the the css class .hideTextBox into the head section of the current page. This css class is used to hide the //FormTextBox that holds the title of the event this.Page.Header.Controls.Add(new LiteralControl("<style type=\"text/css\"> .hideTextBox {display: none !important;} </style>")); //Get the event by the current url int index = HttpContext.Current.Request.Url.AbsolutePath.LastIndexOf('/') + 1; eventUrlName = HttpContext.Current.Request.Url.AbsolutePath.Substring(index); if (!SingleWidgetPerEachEvent) { currentEvent = GetEventByUrl(eventUrlName); //Check whether a custom field with the name Thumbnail exists var productField = App.WorkWith().DynamicData().Type(typeof(Event)).Fields().Where(f => f.FieldName == FieldProductName).Get().SingleOrDefault(); if (currentEvent != null && productField != null && !currentEvent.GetValue(FieldProductName).ToString().IsNullOrEmpty()) ProductId = new Guid(currentEvent.GetValue(FieldProductName).ToString()); if (currentEvent != null && productField != null && currentEvent.GetValue(FieldProductName).ToString().IsNullOrEmpty()) { this.Visible = false; } } //Hide the text field that holds the event name foreach (var fieldControl in this.FieldControls) { if (fieldControl is FormTextBox && ((FormTextBox)fieldControl).MetaField.FieldName == FormFieldForEvents) { //Holds the FormTextBox with the event's title textBox = ((FormTextBox)fieldControl); //Hide the FormTextBox with CSS textBox.CssClass = "hideTextBox"; //Sets the Value of the FormTextBox to the title of the event if (currentEvent != null) ((FormTextBox)textBox).DefaultStringValue = currentEvent.Title.ToString(); else ((FormTextBox)textBox).DefaultStringValue = EventsName; } } }
protected override void CreateForm() { OpenGroup("Container"); #region Defaults OrderElements = OrderElements.LabelMarkInput; Required = true; RequiredMessage = resFieldRequired; #endregion #region Title AddItem(new FormTitle("Title") { Content = resAdults, }); #endregion #region DateOfBirth AddItem(dtpDateOfBirth = new FormDatePicker("DateOfBirth", "dd/mm/yyyy") { Label = resDateOfBirth, Placeholder = resDateOfBirth, Validator = (v) => { if (v > DateTime.Now) { return(resDateInvalid); } return(null); } }); #endregion #region EmploymentStatus AddItem(rdgEmploymentStatus = new FormRadioGroup("EmploymentStatus") { Label = resEmploymentStatus, Required = true, Update = true, Content = tblEmploymentStatus.ListAll().Select(s => new FormRadioButton(s.id, s.descr)) }); #endregion #region EmploymentDuration AddItem(selEmploymentDuration = new FormSelect("EmploymentDuration", false) { Label = resEmploymentDuration, Header = new FormOption(resChoose), Hidden = true, Content = tblEmploymentDuration.ListAll().Select(d => new FormOption(d.id, d.descr)) }); #endregion #region EducationalLevel AddItem(selEducationalLevel = new FormSelect("EducationalLevel", false) { Label = resEducationalLevel, Header = new FormOption(resChoose), Content = tblEducationalLevel.ListAll().Select(l => new FormOption(l.id, l.name)) }); #endregion #region Population AddItem(selPopulation = new FormSelect("Population", false) { Label = resCity, Header = new FormOption(resChoose), Content = tblPopulation.ListAll().Select(p => new FormOption(p.id, p.descr)) }); #endregion #region City AddItem(selCity = new FormSelect("City", false) { Label = resAreaOfResidence, Header = new FormOption(resChoose), Update = true, Content = tblCity.ListAll().OrderBy(c => c.name).Select(c => new FormOption(c.id, c.name)) }); #endregion #region Municipality AddItem(selMunicipality = new FormSelect("MunicipalitySelect", false) { Label = resMunicipality, Header = new FormOption(resChoose), Hidden = true, }); AddItem(txtMunicipality = new FormTextBox("MunicipalityTextBox") { Label = resMunicipality, Hidden = true, }); #endregion #region Submit AddItem(new FormButton("Submit") { Content = resSend, Submit = true }); #endregion CloseGroup("Container"); }