Ejemplo n.º 1
0
        private DynamicTable buildTree(string name, IEnumerable <MergeRow> emptyRowTree)
        {
            var singleRow = emptyRowTree.Single();

            var table = new DynamicTable(new EwfTableColumn("Field name"), new EwfTableColumn("Description"))
            {
                Caption = name
            };

            foreach (var field in singleRow.Values)
            {
                table.AddTextRow(getFieldNameCellText(field), field.GetDescription());
            }

            foreach (var child in singleRow.Children)
            {
                var panel = new Panel();
                panel.Style.Add(HtmlTextWriterStyle.MarginLeft, "2em");
                panel.Controls.Add(buildTree(child.NodeName, child.Rows));

                table.AddRow(panel.ToCell(new TableCellSetup(fieldSpan: 2)));
            }

            return(table);
        }
        private void addFileRow(DynamicTable table, BlobFile file, ActionPostBack deletePb, List <Func <bool> > deleteModMethods)
        {
            var cells = new List <EwfTableCell>();

            var thumbnailControl = BlobFileOps.GetThumbnailControl(file, ThumbnailResourceInfoCreator);

            if (thumbnailControl != null)
            {
                cells.Add(thumbnailControl);
            }

            var fileIsUnread = fileIdsMarkedAsRead != null && !fileIdsMarkedAsRead.Contains(file.FileId);

            cells.Add(
                new PostBackButton(
                    PostBack.CreateFull(
                        id: PostBack.GetCompositeId(postBackIdBase, file.FileId.ToString()),
                        firstModificationMethod: () => {
                if (fileIsUnread && markFileAsReadMethod != null)
                {
                    markFileAsReadMethod(file.FileId);
                }
            },
                        actionGetter: () => new PostBackAction(new SecondaryResponse(new BlobFileResponse(file.FileId, () => true), false))),
                    new TextActionControlStyle(file.FileName),
                    false)
            {
                ToolTip = file.FileName
            });

            cells.Add(file.UploadedDate.ToDayMonthYearString(false));
            cells.Add((fileIsUnread ? "New!" : "").ToCell(new TableCellSetup(classes: "ewfNewness".ToSingleElementArray())));

            var delete         = false;
            var deleteCheckBox =
                FormItem.Create(
                    "",
                    new EwfCheckBox(false, postBack: deletePb),
                    validationGetter: control => new EwfValidation((pbv, v) => { delete = control.IsCheckedInPostBack(pbv); }, deletePb)).ToControl();

            cells.Add(ReadOnly ? null : deleteCheckBox);
            deleteModMethods.Add(
                () => {
                if (!delete)
                {
                    return(false);
                }
                BlobFileOps.SystemProvider.DeleteFile(file.FileId);
                return(true);
            });

            table.AddRow(cells.ToArray());
        }
        private void buildNavigationBox()
        {
            var jumpList =
                SelectList.CreateDropDown(
                    from i in Enumerable.Range(-3, 7) select SelectListItem.Create(i, formatDateTimeForJumpList(adjustDateByNumberOfIntervals(date, i))),
                    0,
                    autoPostBack: true);

            jumpList.Width = JumpListWidth;
            var numIntervals = 0;

            EwfPage.Instance.DataUpdate.AddTopValidationMethod((pbv, validator) => numIntervals = jumpList.ValidateAndGetSelectedItemIdInPostBack(pbv, validator));
            EwfPage.Instance.DataUpdate.AddModificationMethod(() => dateModificationMethod(adjustDateByNumberOfIntervals(date, numIntervals)));


            var previousLink =
                new PostBackButton(
                    PostBack.CreateFull(id: "prev", firstModificationMethod: () => dateModificationMethod(adjustDateByNumberOfIntervals(date, -1))),
                    PreviousButton,
                    usesSubmitBehavior: false);
            var todayLink = new PostBackButton(
                PostBack.CreateFull(id: "today", firstModificationMethod: () => dateModificationMethod(DateTime.Today)),
                CurrentDateButton,
                usesSubmitBehavior: false);
            var nextLink =
                new PostBackButton(
                    PostBack.CreateFull(id: "next", firstModificationMethod: () => dateModificationMethod(adjustDateByNumberOfIntervals(date, 1))),
                    NextButton,
                    usesSubmitBehavior: false);

            var table = new DynamicTable {
                CssClass = "calendarViewHeader ewfNavigationBoxHeader", IsStandard = false
            };
            var navControls = new Panel();

            foreach (var postBackButton in new List <PostBackButton> {
                previousLink, todayLink, nextLink
            })
            {
                navControls.Controls.Add(postBackButton);
            }

            table.AddRow(jumpList, navControls.ToCell(new TableCellSetup(classes: "calendarViewNavButtons".ToSingleElementArray())));
            Controls.Add(table);
        }
Ejemplo n.º 4
0
        void ControlTreeDataLoader.LoadData()
        {
            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;
            }
        }