Пример #1
0
        public void Create(PrintElementNodeBuilder builder, ICollection <PrintElementNode> elements,
                           PrintElementNode elementNode)
        {
            elementNode.ElementChildrenTypes = BuildHelper.BlockTypes;
            elementNode.CanInsertChild       = BuildHelper.CanInsertChild(elementNode);
            elementNode.InsertChild          = BuildHelper.InsertChildToCollection(builder, elements, elementNode, "Blocks");

            elementNode.CanDeleteChild = BuildHelper.CanDeleteChild(elementNode);
            elementNode.DeleteChild    = BuildHelper.DeleteChildFromCollection(elements, elementNode, "Blocks");

            elementNode.CanMoveChild = BuildHelper.CanMoveChild(elementNode);
            elementNode.MoveChild    = BuildHelper.MoveChildInCollection(elementNode, "Blocks");

            elementNode.CanPaste = BuildHelper.CanPaste(elementNode);
            elementNode.Paste    = BuildHelper.Paste(elementNode);

            builder.BuildElements(elements, elementNode, elementNode.ElementMetadata.Blocks);
        }
        private static Func <PrintElementNode, bool, bool> DeleteTableColumn(ICollection <PrintElementNode> elements,
                                                                             PrintElementNode parentElementNode)
        {
            // Удаление столбца удаляет соответствующие ячейки во всех строчках таблицы

            var getTableRowsFunc = GetTableRows(parentElementNode);
            var deleteChildFunc  = BuildHelper.DeleteChildFromCollection(elements, parentElementNode, "Columns", false);

            return((columnElementNode, accept) =>
            {
                var columnIndex = columnElementNode.Index;

                if (deleteChildFunc(columnElementNode, accept))
                {
                    var rows = getTableRowsFunc();

                    if (rows != null)
                    {
                        foreach (var row in rows)
                        {
                            foreach (var cell in row.Nodes)
                            {
                                if (cell.Index == columnIndex)
                                {
                                    row.DeleteChild.TryInvoke(cell, false);
                                    break;
                                }
                            }
                        }
                    }

                    return true;
                }

                return false;
            });
        }
Пример #3
0
        public void Create(PrintElementNodeBuilder builder, ICollection <PrintElementNode> elements,
                           PrintElementNode elementNode)
        {
            elementNode.ElementChildrenTypes = TableCells;
            elementNode.CanInsertChild       = CanInsertTableRowCell(elementNode);
            elementNode.InsertChild          = BuildHelper.InsertChildToCollection(builder, elements, elementNode, "Cells", false);

            elementNode.CanDeleteChild = CanDeleteTableRowCell(elementNode);
            elementNode.DeleteChild    = BuildHelper.DeleteChildFromCollection(elements, elementNode, "Cells", false);

            elementNode.CanMoveChild = BuildHelper.CanMoveChild(elementNode);
            elementNode.MoveChild    = BuildHelper.MoveChildInCollection(elementNode, "Cells", false);

            elementNode.CanCut = BuildHelper.CanCut(elementNode);
            elementNode.Cut    = BuildHelper.Cut(elementNode);

            elementNode.CanCopy = BuildHelper.CanCopy(elementNode);
            elementNode.Copy    = BuildHelper.Copy(elementNode);

            elementNode.CanPaste = BuildHelper.CanPaste(elementNode);
            elementNode.Paste    = BuildHelper.Paste(elementNode);

            builder.BuildElements(elements, elementNode, elementNode.ElementMetadata.Cells, "TableCell");
        }
 private static Func <PrintElementNode, bool, bool> DeleteTableRow(ICollection <PrintElementNode> elements,
                                                                   PrintElementNode parentElementNode)
 {
     return(BuildHelper.DeleteChildFromCollection(elements, parentElementNode, "Rows", false));
 }