Ejemplo n.º 1
0
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                var table = new DynamicTable {
                    IsStandard = false
                };

                var controls = codeControls;
                if (HideIfEmpty && controls.Count == 0)
                {
                    Visible = false;
                    return;
                }
                var firstPassThroughRowLoop = true;
                for (var i = 0; i < controls.Count; i += NumberOfColumns)
                {
                    // spacer row
                    if (!firstPassThroughRowLoop)
                    {
                        var spacerRowCount = SpacerCellSetup.RowSpacerCellCreator().Count;
                        for (var spacerRowIndex = 0; spacerRowIndex < spacerRowCount; spacerRowIndex += 1)
                        {
                            var firstPassThroughSpacerRowColumnLoop = true;
                            var spacerRowCells = new List <EwfTableCell>();
                            for (var spacerRowColumnIndex = 0; spacerRowColumnIndex < NumberOfColumns; spacerRowColumnIndex += 1)
                            {
                                if (!firstPassThroughSpacerRowColumnLoop)
                                {
                                    spacerRowCells.AddRange(SpacerCellSetup.RowAndColumnSpacerCellCreator()[spacerRowIndex]);
                                }
                                spacerRowCells.Add(SpacerCellSetup.RowSpacerCellCreator()[spacerRowIndex]);
                                firstPassThroughSpacerRowColumnLoop = false;
                            }
                            table.AddRow(spacerRowCells.ToArray());
                        }
                    }

                    // content row
                    var firstPassThroughColumnLoop = true;
                    var cells = new List <EwfTableCell>();
                    for (var columnIndex = 0; columnIndex < NumberOfColumns; columnIndex += 1)
                    {
                        // spacer cells
                        if (!firstPassThroughColumnLoop)
                        {
                            cells.AddRange(SpacerCellSetup.ColumnSpacerCellCreator());
                        }

                        // content cell

                        if (firstPassThroughRowLoop && CaptionControl != null)
                        {
                            cells.Add(CaptionControl);
                            i -= NumberOfColumns;
                        }
                        else
                        {
                            var controlIndex = i + columnIndex;
                            if (controlIndex < controls.Count)
                            {
                                cells.Add(controls[controlIndex]);
                            }
                            else
                            {
                                cells.Add(EmptyCellCreator());
                            }
                        }
                        firstPassThroughColumnLoop = false;
                    }
                    table.AddRow(cells.ToArray());

                    firstPassThroughRowLoop = false;
                }

                Controls.Add(table);
            });
        }
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace("ewfStandardFileCollectionManager");

            if (AppRequestState.Instance.Browser.IsInternetExplorer())
            {
                base.Controls.Add(
                    new HtmlGenericControl("p")
                {
                    InnerText =
                        "Because you are using Internet Explorer, clicking on a file below will result in a yellow warning bar appearing near the top of the browser.  You will need to then click the warning bar and tell Internet Explorer you are sure you want to download the file."
                });
            }

            var columnSetups = new List <ColumnSetup>();

            if (ThumbnailResourceInfoCreator != null)
            {
                columnSetups.Add(new ColumnSetup {
                    Width = Unit.Percentage(10)
                });
            }
            columnSetups.Add(new ColumnSetup {
                CssClassOnAllCells = "ewfOverflowedCell"
            });
            columnSetups.Add(new ColumnSetup {
                Width = Unit.Percentage(13)
            });
            columnSetups.Add(new ColumnSetup {
                Width = Unit.Percentage(7)
            });
            columnSetups.Add(new ColumnSetup {
                Width = Unit.Percentage(23), CssClassOnAllCells = "ewfRightAlignCell"
            });

            var table = new DynamicTable(columnSetups.ToArray())
            {
                Caption = Caption
            };

            files = BlobFileOps.SystemProvider.GetFilesLinkedToFileCollection(fileCollectionId);
            files = (sortByName ? files.OrderByName() : files.OrderByUploadedDateDescending()).ToArray();

            var deletePb         = PostBack.CreateFull(id: PostBack.GetCompositeId(postBackIdBase, "delete"));
            var deleteModMethods = new List <Func <bool> >();

            foreach (var file in files)
            {
                addFileRow(table, file, deletePb, deleteModMethods);
            }
            if (!ReadOnly)
            {
                table.AddRow(
                    getUploadControlList().ToCell(new TableCellSetup(fieldSpan: ThumbnailResourceInfoCreator != null ? 3 : 2)),
                    (files.Any() ? new PostBackButton(deletePb, new ButtonActionControlStyle("Delete Selected Files"), usesSubmitBehavior: false) : null).ToCell(
                        new TableCellSetup(fieldSpan: 2, classes: "ewfRightAlignCell".ToSingleElementArray())));
            }
            deletePb.AddModificationMethod(
                () => {
                if (deleteModMethods.Aggregate(false, (deletesOccurred, method) => method() || deletesOccurred))
                {
                    EwfPage.AddStatusMessage(StatusMessageType.Info, "Selected files deleted successfully.");
                }
            });

            Controls.Add(table);

            if (ReadOnly && !files.Any())
            {
                Visible = false;
            }
        }