private EwfTableItemGroup getItemGroup(int groupNumber) { var updateRegionSet = new UpdateRegionSet(); return(EwfTableItemGroup.Create( () => new EwfTableItemGroupRemainingData( "Group {0}".FormatWith(groupNumber).ToComponents(), groupActions: groupNumber == 2 ? new ButtonSetup( "Action 1", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: PostBack.GetCompositeId(groupNumber.ToString(), "action1"), modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 1")))).Append( new ButtonSetup( "Action 2", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: PostBack.GetCompositeId(groupNumber.ToString(), "action2"), modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 2"))))) .Materialize() : null, groupHeadActivationBehavior: ElementActivationBehavior.CreateButton( new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: "group{0}".FormatWith(groupNumber), modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "You clicked group {0}.".FormatWith(groupNumber))))), tailUpdateRegions: groupNumber == 1 ? new TailUpdateRegion(updateRegionSet.ToCollection(), 1).ToCollection() : null), groupNumber == 1 ? getItems(FirstGroupItemCount, true) .Concat( new Func <EwfTableItem>( () => EwfTableItem.Create( new EwfButton( new StandardButtonStyle("Add Row"), behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( updateRegionSet.ToCollection(), id: "addRow", modificationMethod: () => parametersModification.FirstGroupItemCount += 1))).ToCollection() .ToCell(), "".ToCell())).ToCollection()) : getItems(250, false), selectedItemActions: groupNumber == 1 ? SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>( "Echo group IDs", null, ids => AddStatusMessage( StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true))) .ToCollection() : Enumerable.Empty <SelectedItemAction <int> >().Materialize())); }
internal EwfTableFieldOrItemSetup( ElementClassSet classes, CssLength size, TextAlignment textAlignment, TableCellVerticalAlignment verticalAlignment, ElementActivationBehavior activationBehavior) { Classes = classes ?? ElementClassSet.Empty; Size = size; TextAlignment = textAlignment; VerticalAlignment = verticalAlignment; ActivationBehavior = activationBehavior; }
private IEnumerable <Func <EwfTableItem> > getItems(int count, bool includeId) { return(from i in Enumerable.Range(1, count) select new Func <EwfTableItem>( () => EwfTableItem.Create( EwfTableItemSetup.Create( activationBehavior: ElementActivationBehavior.CreateHyperlink(ActionControls.GetInfo()), id: includeId ? new SpecifiedValue <int>(i) : null), i.ToString().ToCell(), ((i * 2) + Environment.NewLine + "extra stuff").ToCell()))); }
protected override PageContent getContent() { var content = new UiPageContent(omitContentBox: true); if (UserManagementStatics.IdentityProviders.OfType <SamlIdentityProvider>().Any()) { var certificate = UserManagementStatics.GetCertificate(); content.Add( new Section( "Identity providers", FormItemList.CreateStack( items: (certificate.Any() ? "Certificate valid until {0}.".FormatWith( new X509Certificate2(Convert.FromBase64String(certificate), UserManagementStatics.CertificatePassword).NotAfter .ToDayMonthYearString( false)) .ToComponents() : "No certificate.".ToComponents()).Concat(" ".ToComponents()) .Append( new EwfButton( new StandardButtonStyle("Regenerate", buttonSize: ButtonSize.ShrinkWrap), behavior: new ConfirmationButtonBehavior( "Are you sure?".ToComponents(), postBack: PostBack.CreateFull( "certificate", modificationMethod: () => UserManagementStatics.UpdateCertificate(generateCertificate(DateTimeOffset.UtcNow)))))) .Materialize() .ToFormItem(label: "System self-signed certificate".ToComponents()) .Concat( AuthenticationStatics.SamlIdentityProviders.Any() ? new EwfHyperlink(EnterpriseWebFramework.UserManagement.SamlResources.Metadata.GetInfo(), new StandardHyperlinkStyle("")) .ToFormItem(label: "Application SAML metadata".ToComponents()) .ToCollection() : Enumerable.Empty <FormItem>()) .Materialize()) .ToCollection(), style: SectionStyle.Box)); } content.Add( new Section( "System users", EwfTable.Create( tableActions: new HyperlinkSetup(new SystemUser(Es, null), "Create User").ToCollection(), headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection()) .AddData( UserManagementStatics.SystemProvider.GetUsers(), user => EwfTableItem.Create( user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(), setup: EwfTableItemSetup.Create(activationBehavior: ElementActivationBehavior.CreateHyperlink(new SystemUser(Es, user.UserId))))) .ToCollection(), style: SectionStyle.Box)); return(content); }
private EwfTableItemSetup( ElementClassSet classes, CssLength size, TextAlignment textAlignment, TableCellVerticalAlignment verticalAlignment, ElementActivationBehavior activationBehavior, SpecifiedValue <int> id, int?rankId) : base( classes, size, textAlignment, verticalAlignment, activationBehavior, id, rankId) { }
protected override void loadData() { ph.AddControlsReturnThis( EwfTable .Create( tableActions: new HyperlinkSetup(new EditUser.Info(es.info, null), "Create User").ToCollection(), headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection()) .AddData( UserManagementStatics.GetUsers(), user => EwfTableItem.Create( user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(), setup: EwfTableItemSetup.Create( activationBehavior: ElementActivationBehavior.CreateRedirectScript(new EditUser.Info(es.info, user.UserId))))) .ToCollection() .GetControls()); }
protected override void loadData() { var itemGroups = Enumerable.Range(1, 2) .Select( group => ColumnPrimaryItemGroup.Create( "Group {0}".FormatWith(group).ToComponents(), groupActions: new ButtonSetup( "Action 1", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: PostBack.GetCompositeId(group.ToString(), "action1"), firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 1")))).Append( new ButtonSetup( "Action 2", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: PostBack.GetCompositeId(group.ToString(), "action2"), firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 2"))))) .Materialize(), selectedItemActions: group == 1 ? SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>( "Echo group IDs", null, ids => AddStatusMessage( StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true))) .ToCollection() : Enumerable.Empty <SelectedItemAction <int> >().Materialize(), items: Enumerable.Range(1, 5) .Select( i => EwfTableItem.Create( EwfTableItemSetup.Create( activationBehavior: ElementActivationBehavior.CreateRedirectScript(ActionControls.GetInfo()), id: new SpecifiedValue <int>(group * 10 + i)), i.ToString().ToCell(), ((i * 2) + Environment.NewLine + "extra stuff").ToCell())))) .Materialize(); place.AddControlsReturnThis( ColumnPrimaryTable.Create( caption: "My table", subCaption: "A new table implementation", allowExportToExcel: true, tableActions: new ButtonSetup( "Action", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: "action", firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "You clicked action.")))).ToCollection(), selectedItemActions: SelectedItemAction .CreateWithIntermediatePostBackBehavior <int>( "Echo IDs", null, ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true))) .Append( SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>( "With confirmation", null, ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)), confirmationDialogContent: "Are you sure?".ToComponents())) .Materialize(), fields: new[] { new EwfTableField(size: 1.ToPercentage()), new EwfTableField(size: 2.ToPercentage()) }) .AddItemGroups(itemGroups) .ToCollection() .GetControls()); }
public void RealWorldDataTableTest() { // This is what a dynamic table would output, a list of rowsetups. var rowSetups = new List <RowSetup>(); rowSetups.Add( new RowSetup { IsHeader = true, CsvLine = new List <string> { "Name", "Company", "Location", "Url", "Phone" } }); var names = new[] { "Sofeee", "Cathie", "Ann", "Jan", "Patty", "Cora" }; var surNames = new[] { "Norjaim", "Carbelt", "Wilson", "Middleberger", "Hewlett", "Taylor", "Danzen" }; var companies = new[] { "Synergy", "Enterprises", "Dancing", "Buzz", "Local", "of Rochester" }; var streets = new[] { "Broad Rd", "W Elm St", "Main", "James Ave", "Water Blvd", "West Way" }; for (var i = 0; i < 72; i++) { rowSetups.Add( new RowSetup { CsvLine = new List <string> { // Some random-looking values names[i % names.Count()] + " " + surNames[i % surNames.Count()], companies[(i + (i / 2)) % companies.Count()] + " " + companies[i % companies.Count()], i + " " + streets[i % streets.Count()], "http://www.google.com/search?q=" + i, i.ToString("D3") + "-867-5309" }, ActivationBehavior = ElementActivationBehavior.CreateRedirectScript(new ExternalResourceInfo("http://google.com")), CssClass = "gibberish_string_for_testing", IsHeader = false, RankId = i, UniqueIdentifier = "row" + i }); } runTest( writer => { foreach (var rowSetup in rowSetups) { if (rowSetup.IsHeader) { writer.DefaultWorksheet.AddHeaderToWorksheet(rowSetup.CsvLine.ToArray()); } else { writer.DefaultWorksheet.AddRowToWorksheet(rowSetup.CsvLine.ToArray()); } } return("data_table"); }); }
/// <summary> /// Creates an item setup object with a specified ID type. /// </summary> /// <param name="classes">The classes. When used on a column, sets the classes on every cell since most styles don't work on col elements.</param> /// <param name="size">The height or width. For an EWF table, this is the row height. For a column primary table, this is the column width. If you specify /// percentage widths for some or all columns in a table, these values need not add up to 100; they will be automatically scaled if necessary. The automatic /// scaling will not happen if there are any columns without a specified width.</param> /// <param name="textAlignment">The text alignment of the cells in this item.</param> /// <param name="verticalAlignment">The vertical alignment of the cells in this item.</param> /// <param name="activationBehavior">The activation behavior.</param> /// <param name="id">A value that uniquely identifies this item in table-level and group-level item actions. If you specify this, the item will have a /// checkbox that enables it to be included in the actions.</param> /// <param name="rankId">The rank ID for this item, which is used for item reordering.</param> public static EwfTableItemSetup <IdType> CreateWithIdType <IdType>( ElementClassSet classes = null, CssLength size = null, TextAlignment textAlignment = TextAlignment.NotSpecified, TableCellVerticalAlignment verticalAlignment = TableCellVerticalAlignment.NotSpecified, ElementActivationBehavior activationBehavior = null, SpecifiedValue <IdType> id = null, int?rankId = null) => new EwfTableItemSetup <IdType>(classes, size, textAlignment, verticalAlignment, activationBehavior, id, rankId);