Exemplo n.º 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="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);
            })));
        }
Exemplo n.º 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="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)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a form item.
        /// </summary>
        protected FormItem(FormItemLabel label, Control control, int?cellSpan, TextAlignment textAlignment, EwfValidation 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;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a form item with this form control and the specified label. Cell span only applies to adjacent layouts.
        /// </summary>
        public static FormItem ToFormItem(
            this FormControl <FlowComponentOrNode> formControl, FormItemLabel label, int?cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified)
        {
            // Web Forms compatibility. Remove when EnduraCode goal 790 is complete.
            var webControl = formControl as WebControl;

            if (webControl != null)
            {
                return(new FormItem <Control>(label, webControl, cellSpan, textAlignment, formControl.Validation));
            }

            return(new FormItem <Control>(
                       label,
                       new PlaceHolder().AddControlsReturnThis(formControl.PageComponent.ToCollection().GetControls()),
                       cellSpan,
                       textAlignment,
                       formControl.Validation));
        }
Exemplo n.º 5
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, EwfValidation> validationGetter     = null) where ControlType : Control
 {
     return(new FormItem <ControlType>(label, control, cellSpan, textAlignment, validationGetter?.Invoke(control)));
 }