private ComponentListItem getNonIdItem(int i) { var rs = new UpdateRegionSet(); var items = new List <ComponentListItem>(); if (NonIdItemStates.ElementAt(i) == 1) { items.Add(new TextControl("Item {0}".FormatWith(i), true).ToFormItem().ToListItem()); } else { items.Add("Item {0}".FormatWith(i).ToComponents().ToComponentListItem()); } items.Add( new EwfButton( new StandardButtonStyle("Toggle", buttonSize: ButtonSize.ShrinkWrap), behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( rs.ToCollection(), id: PostBack.GetCompositeId("nonId", i.ToString()), modificationMethod: () => parametersModification.NonIdItemStates = parametersModification.NonIdItemStates.Select((state, index) => index == i ? (state + 1) % 2 : state)))) .ToCollection() .ToComponentListItem()); return(new StackList(items).ToCollection().ToComponentListItem(updateRegionSets: rs.ToCollection())); }
private IReadOnlyCollection <FlowComponent> getNonIdListRegionComponents() { var components = new List <FlowComponent>(); var addRs = new UpdateRegionSet(); var removeRs = new UpdateRegionSet(); components.Add( new LineList( new EwfButton( new StandardButtonStyle("Add Two Items"), behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( addRs.ToCollection(), id: "nonIdAdd", modificationMethod: () => parametersModification.NonIdItemStates = parametersModification.NonIdItemStates.Concat(new[] { 0, 0 })))) .ToCollection() .Append( new EwfButton( new StandardButtonStyle("Remove Two Items"), behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( removeRs.ToCollection(), id: "nonIdRemove", modificationMethod: () => parametersModification.NonIdItemStates = parametersModification.NonIdItemStates.Take(parametersModification.NonIdItemStates.Count() - 2))))) .Select(i => (LineListItem)i.ToCollection().ToComponentListItem()))); var stack = new StackList( Enumerable.Range(0, NonIdItemStates.Count()).Select(getNonIdItem), setup: new ComponentListSetup( tailUpdateRegions: new[] { new TailUpdateRegion(addRs.ToCollection(), 0), new TailUpdateRegion(removeRs.ToCollection(), 2) })); components.Add(new Section("Control List With Non-ID Items", stack.ToCollection(), style: SectionStyle.Box)); return(components); }