Пример #1
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="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 <ChangeBasedListItemWithSelectionState <ItemIdType> > items, out Action modificationMethod, string caption = "",
            bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, PostBack postBack = null, int?cellSpan = null,
            TextAlignment textAlignment             = TextAlignment.NotSpecified, Func <bool> validationPredicate = null, ValidationList validationList = 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,
                postBack);

            modificationMethod = checkBoxList.ModifyData;
            return(FormItem.Create(
                       label,
                       checkBoxList,
                       cellSpan: cellSpan,
                       textAlignment: textAlignment,
                       validationGetter: control => new Validation(
                           (pbv, validator) => {
                if (validationPredicate != null && !validationPredicate())
                {
                    return;
                }
                control.Validate(pbv);
            },
                           validationList ?? EwfPage.Instance.DataUpdate)));
        }
Пример #2
0
        /// <summary>
        /// Creates a form item.
        /// </summary>
        protected FormItem(FormItemLabel label, Control control, int?cellSpan, TextAlignment textAlignment, Validation validation)
        {
            if (label == null)
            {
                throw new ApplicationException("The label cannot be a null FormItemLabel reference.");
            }
            this.label = label;

            this.control       = control;
            this.cellSpan      = cellSpan;
            this.textAlignment = textAlignment;
            this.validation    = validation;
        }
Пример #3
0
 /// <summary>
 /// Creates a form item with the given label and control. Cell span only applies to adjacent layouts.
 /// </summary>
 // By taking a FormItemLabel instead of a Control for label, we retain the ability to implement additional behavior for string labels, such as automatically
 // making them bold.
 public static FormItem <ControlType> Create <ControlType>(
     FormItemLabel label, ControlType control, int?cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified,
     Func <ControlType, Validation> validationGetter        = null) where ControlType : Control
 {
     return(new FormItem <ControlType>(label, control, cellSpan, textAlignment, validationGetter != null ? validationGetter(control) : null));
 }