public static FormItem <WysiwygHtmlEditor> GetBodyHtmlFormItem(this EmailMessage emailMessage, ValidationList vl, string value = "")
 {
     return(FormItem.Create(
                "Body",
                new WysiwygHtmlEditor(value),
                validationGetter: control => new EwfValidation((pbv, validator) => emailMessage.BodyHtml = control.GetPostBackValue(pbv), vl)));
 }
示例#2
0
        /// <summary>
        /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute
        /// set of selected items.
        /// </summary>
        /// <typeparam name="ItemIdType"></typeparam>
        /// <param name="label"></param>
        /// <param name="items"></param>
        /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param>
        /// <param name="caption"></param>
        /// <param name="includeSelectAndDeselectAllButtons"></param>
        /// <param name="numberOfColumns"></param>
        /// <param name="action"></param>
        /// <param name="cellSpan"></param>
        /// <param name="textAlignment"></param>
        /// <param name="validationPredicate"></param>
        /// <returns></returns>
        public static FormItem GetFormItem <ItemIdType>(
            FormItemLabel label, IEnumerable <ChangeBasedListItemWithSelectionState <ItemIdType> > items, out Action modificationMethod, string caption = "",
            bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, FormAction action = null, int?cellSpan = null,
            TextAlignment textAlignment             = TextAlignment.NotSpecified, Func <bool> validationPredicate = null)
        {
            var itemArray         = items.ToArray();
            var selectedItemIds   = itemArray.Where(i => i.IsSelected).Select(i => i.Item.Item.Id);
            var uiSelectedItemIds = itemArray.Where(i => i.IsSelectedInUi).Select(i => i.Item.Item.Id);
            var checkBoxList      = new ChangeBasedCheckBoxList <ItemIdType>(
                itemArray.Select(i => i.Item),
                selectedItemIds,
                caption,
                includeSelectAndDeselectAllButtons,
                numberOfColumns,
                uiSelectedItemIds,
                action);

            modificationMethod = checkBoxList.ModifyData;
            return(FormItem.Create(
                       label,
                       checkBoxList,
                       cellSpan: cellSpan,
                       textAlignment: textAlignment,
                       validationGetter: control => new EwfValidation(
                           (pbv, validator) => {
                if (validationPredicate != null && !validationPredicate())
                {
                    return;
                }
                control.Validate(pbv);
            })));
        }
示例#3
0
        /// <summary>
        /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute
        /// set of selected items.
        /// </summary>
        /// <typeparam name="ItemIdType"></typeparam>
        /// <param name="label"></param>
        /// <param name="items"></param>
        /// <param name="selectedItemIds"></param>
        /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param>
        /// <param name="caption"></param>
        /// <param name="includeSelectAndDeselectAllButtons"></param>
        /// <param name="numberOfColumns"></param>
        /// <param name="uiSelectedItemIds"></param>
        /// <param name="postBack"></param>
        /// <param name="cellSpan"></param>
        /// <param name="textAlignment"></param>
        /// <param name="validationPredicate"></param>
        /// <param name="validationList"></param>
        /// <returns></returns>
        public static FormItem GetFormItem <ItemIdType>(
            FormItemLabel label, IEnumerable <ChangeBasedListItem <ItemIdType> > items, IEnumerable <ItemIdType> selectedItemIds, out Action modificationMethod,
            string caption                = "", bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, IEnumerable <ItemIdType> uiSelectedItemIds = null,
            PostBack postBack             = null, int?cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified, Func <bool> validationPredicate      = null,
            ValidationList validationList = null)
        {
            var checkBoxList = new ChangeBasedCheckBoxList <ItemIdType>(
                items,
                selectedItemIds,
                caption,
                includeSelectAndDeselectAllButtons,
                numberOfColumns,
                uiSelectedItemIds ?? selectedItemIds,
                postBack);

            modificationMethod = checkBoxList.ModifyData;
            return(FormItem.Create(
                       label,
                       checkBoxList,
                       cellSpan: cellSpan,
                       textAlignment: textAlignment,
                       validationGetter: control => new EwfValidation(
                           (pbv, validator) => {
                if (validationPredicate != null && !validationPredicate())
                {
                    return;
                }
                control.Validate(pbv);
            },
                           validationList ?? EwfPage.Instance.DataUpdate)));
        }
示例#4
0
 public static FormItem <EwfTextBox> GetSubjectFormItem(this EmailMessage emailMessage, string value = "")
 {
     return(FormItem.Create(
                "Subject",
                new EwfTextBox(value),
                validationGetter: control => new EwfValidation(
                    (pbv, validator) => {
         emailMessage.Subject = validator.GetString(new ValidationErrorHandler("subject"), control.GetPostBackValue(pbv), false);
         if (Regex.Match(emailMessage.Subject, RegularExpressions.HtmlTag, RegexOptions.IgnoreCase).Success)
         {
             validator.NoteErrorAndAddMessage("HTML is not allowed in the subject field.");
         }
     })));
 }
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                if (hideIfEmpty && !formItems.Any())
                {
                    Visible = false;
                    return;
                }

                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
                if (IncludeButtonWithThisText != null)
                {
                    // We need to do logic to get the button to be on the right of the row.
                    if (useFormItemListMode && numberOfColumns.HasValue)
                    {
                        var widthOfLastRowWithButton     = getFormItemRows(formItems, numberOfColumns.Value).Last().Sum(getCellSpan) + defaultFormItemCellSpan;
                        var numberOfPlaceholdersRequired = 0;
                        if (widthOfLastRowWithButton < numberOfColumns.Value)
                        {
                            numberOfPlaceholdersRequired = numberOfColumns.Value - widthOfLastRowWithButton;
                        }
                        if (widthOfLastRowWithButton > numberOfColumns.Value)
                        {
                            numberOfPlaceholdersRequired = numberOfColumns.Value - ((widthOfLastRowWithButton - numberOfColumns.Value) % numberOfColumns.Value);
                        }

                        numberOfPlaceholdersRequired.Times(() => formItems.Add(getPlaceholderFormItem()));
                    }
                    formItems.Add(
                        FormItem.Create(
                            "",
                            new PostBackButton(new ButtonActionControlStyle(IncludeButtonWithThisText), postBack: EwfPage.Instance.DataUpdatePostBack)
                    {
                        Width = Unit.Percentage(50)
                    },
                            textAlignment: TextAlignment.Right,
                            cellSpan: defaultFormItemCellSpan));
                }
                Controls.Add(useFormItemListMode ? getTableForFormItemList() : getTableForFormItemTable());
            });
        }
 private FormItem <Literal> getPlaceholderFormItem()
 {
     return(FormItem.Create("", "".GetLiteralControl(), cellSpan: 1));
 }
 private FormItem getPlaceholderFormItem()
 {
     return(FormItem.Create("", new PlaceHolder().AddControlsReturnThis("".ToComponents().GetControls()), cellSpan: 1));
 }