Beispiel #1
0
        private void AddRow(TreeViewSpreadExportRow row, int currentRowIndex)
        {
            int index1 = 0;

            for (int index2 = 0; index2 < row.Cells.Count; ++index2)
            {
                TreeViewSpreadExportCell cell1 = row.Cells[index2];
                if (this.columnWidths.Count <= index1)
                {
                    this.columnWidths.Add(0);
                }
                if (cell1 is TreeViewSpreadExportIndentCell)
                {
                    if (cell1.Size.Width > this.columnWidths[index1])
                    {
                        this.columnWidths[index1] = cell1.Size.Width;
                        this.spreadExportRenderer.SetWorksheetColumnWidth(index1, (double)cell1.Size.Width, false);
                    }
                    this.CreateCell(cell1, currentRowIndex, index1);
                }
                else if (cell1 is TreeViewSpreadExportImageCell)
                {
                    TreeViewSpreadExportImageCell cell2 = cell1 as TreeViewSpreadExportImageCell;
                    if (cell2.Image != null)
                    {
                        this.spreadExportRenderer.SetWorksheetRowHeight(currentRowIndex, cell2.Image.Size.Height, true);
                        if (cell2.Image.Size.Width > this.columnWidths[index1])
                        {
                            this.columnWidths[index1] = cell2.Image.Size.Width;
                            this.spreadExportRenderer.SetWorksheetColumnWidth(index1, (double)cell2.Image.Size.Width, false);
                        }
                        this.CreateImageOverCell(cell2, currentRowIndex, index1);
                    }
                    this.CreateCell((TreeViewSpreadExportCell)cell2, currentRowIndex, index1);
                }
                else
                {
                    this.spreadExportRenderer.SetWorksheetRowHeight(currentRowIndex, cell1.Size.Height, true);
                    int num = this.ExportImages ? this.depthOfTree + 1 : this.depthOfTree;
                    if (cell1.Size.Width > this.columnWidths[index1] && num <= index1)
                    {
                        this.columnWidths[index1] = cell1.Size.Width;
                        this.spreadExportRenderer.SetWorksheetColumnWidth(index1, (double)cell1.Size.Width, false);
                    }
                    this.CreateCell(cell1, currentRowIndex, index1);
                }
                ++index1;
            }
        }
Beispiel #2
0
        private List <TreeViewSpreadExportRow> GetTreeViewDataSnapshot()
        {
            List <TreeViewSpreadExportRow> viewSpreadExportRowList = new List <TreeViewSpreadExportRow>();

            this.defaultItemSize = new Size(this.treeView.Width, this.treeView.ItemHeight);
            if (this.ExportVisualSettings)
            {
                this.elementProvider = this.treeView.TreeViewElement.ViewElement.ElementProvider as TreeViewElementProvider;
            }
            int num = 0;
            IEnumerator <RadTreeNode> enumerator = this.EnumerateNodes().GetEnumerator();
            bool skipHiddenChildNodes            = false;
            bool exportChildNodesHidden          = false;
            int  collapsedParentLevel            = 0;

            if (this.ExportChildNodesGrouped)
            {
                this.InitializeRowGroupDataStructures();
            }
            while (enumerator.MoveNext())
            {
                RadTreeNode current = enumerator.Current;
                if (!skipHiddenChildNodes || collapsedParentLevel >= current.Level)
                {
                    skipHiddenChildNodes = false;
                    TreeViewSpreadExportRow exportRow = this.CreateExportRow(current, num, ref skipHiddenChildNodes, ref collapsedParentLevel, ref exportChildNodesHidden);
                    viewSpreadExportRowList.Add(exportRow);
                    if (this.ExportChildNodesGrouped)
                    {
                        this.ProcessCurrentRowGrouping(current.Level, num);
                    }
                    ++num;
                }
            }
            return(viewSpreadExportRowList);
        }
Beispiel #3
0
        private TreeViewSpreadExportRow CreateExportRow(
            RadTreeNode treeNode,
            int currentRowIndex,
            ref bool skipHiddenChildNodes,
            ref int collapsedParentLevel,
            ref bool exportChildNodesHidden)
        {
            if (!treeNode.Expanded && this.CollapsedNodeOption == HiddenOption.DoNotExport)
            {
                skipHiddenChildNodes = true;
                collapsedParentLevel = treeNode.Level;
            }
            if (exportChildNodesHidden && collapsedParentLevel >= treeNode.Level)
            {
                exportChildNodesHidden = false;
            }
            TreeNodeElement treeNodeElement1 = (TreeNodeElement)null;
            TreeNodeElement treeNodeElement2 = (TreeNodeElement)null;
            int             num = 1;
            RadTreeViewVirtualizedContainer virtualizedContainer = (RadTreeViewVirtualizedContainer)null;
            int height = treeNode.ActualSize.Height == 0 ? this.defaultItemSize.Height : treeNode.ActualSize.Height;

            if (this.ExportVisualSettings)
            {
                virtualizedContainer = this.treeView.TreeViewElement.ViewElement as RadTreeViewVirtualizedContainer;
                if (this.treeView.TreeViewElement.AllowAlternatingRowColor && currentRowIndex % 2 != 0)
                {
                    treeNodeElement1 = new TreeNodeElement();
                    virtualizedContainer.Children.Add((RadElement)treeNodeElement1);
                    num = 2;
                }
                treeNodeElement2 = this.elementProvider.GetElement(treeNode, (object)null) as TreeNodeElement;
                virtualizedContainer.Children.Add((RadElement)treeNodeElement2);
                treeNodeElement2.Attach(treeNode, (object)null);
            }
            TreeViewSpreadExportRow viewSpreadExportRow = new TreeViewSpreadExportRow();

            for (int index = 0; index < treeNode.Level; ++index)
            {
                TreeViewSpreadExportIndentCell exportIndentCell = new TreeViewSpreadExportIndentCell();
                exportIndentCell.Size = new Size(this.NodeIndent, exportChildNodesHidden ? 0 : -1);
                if (this.ExportVisualSettings && treeNodeElement2.LinesContainerElement.LayoutableChildrenCount > 0)
                {
                    this.GetStylesFromVisualCell((TreeViewSpreadExportCell)exportIndentCell, (LightVisualElement)treeNodeElement2.ContentElement);
                }
                this.OnCellFormatting(new TreeViewSpreadExportCellFormattingEventArgs((TreeViewSpreadExportCell)exportIndentCell, treeNode, currentRowIndex));
                viewSpreadExportRow.Cells.Add((TreeViewSpreadExportCell)exportIndentCell);
            }
            if (this.ExportImages)
            {
                TreeViewSpreadExportImageCell spreadExportImageCell = new TreeViewSpreadExportImageCell();
                if (treeNode.Image != null && !exportChildNodesHidden)
                {
                    spreadExportImageCell.Size           = new Size(treeNode.Image.Size.Width, height);
                    spreadExportImageCell.Image          = treeNode.Image;
                    spreadExportImageCell.ImageAlignment = ContentAlignment.MiddleLeft;
                }
                else
                {
                    spreadExportImageCell.Size = new Size(this.NodeIndent, exportChildNodesHidden ? 0 : -1);
                }
                if (this.ExportVisualSettings)
                {
                    if (treeNodeElement2.ImageElement.Image != null)
                    {
                        spreadExportImageCell.Image = treeNodeElement2.ImageElement.Image;
                        spreadExportImageCell.Size  = new Size(treeNodeElement2.ImageElement.Image.Size.Width, height);
                    }
                    spreadExportImageCell.ImageAlignment = treeNodeElement2.ImageElement.ImageAlignment;
                    this.GetStylesFromVisualCell((TreeViewSpreadExportCell)spreadExportImageCell, (LightVisualElement)treeNodeElement2.ContentElement);
                }
                this.OnCellFormatting(new TreeViewSpreadExportCellFormattingEventArgs((TreeViewSpreadExportCell)spreadExportImageCell, treeNode, currentRowIndex));
                viewSpreadExportRow.Cells.Add((TreeViewSpreadExportCell)spreadExportImageCell);
            }
            int width = (treeNode.ActualSize.Width == 0 ? this.defaultItemSize.Width : treeNode.ActualSize.Width) - treeNode.Level * this.NodeIndent;
            TreeViewSpreadExportContentCell exportContentCell = new TreeViewSpreadExportContentCell();

            exportContentCell.Text     = treeNode.Text;
            exportContentCell.Size     = new Size(width, exportChildNodesHidden ? 0 : height);
            exportContentCell.ColSpan += this.depthOfTree - treeNode.Level;
            if (this.ExportVisualSettings)
            {
                this.GetStylesFromVisualCell((TreeViewSpreadExportCell)exportContentCell, (LightVisualElement)treeNodeElement2.ContentElement);
            }
            this.OnCellFormatting(new TreeViewSpreadExportCellFormattingEventArgs((TreeViewSpreadExportCell)exportContentCell, treeNode, currentRowIndex));
            viewSpreadExportRow.Cells.Add((TreeViewSpreadExportCell)exportContentCell);
            if (this.ExportVisualSettings)
            {
                this.elementProvider.CacheElement((IVirtualizedElement <RadTreeNode>)treeNodeElement2);
                treeNodeElement2.Detach();
                virtualizedContainer.Children.Remove((RadElement)treeNodeElement2);
                if (num == 2)
                {
                    virtualizedContainer.Children.Remove((RadElement)treeNodeElement1);
                }
            }
            if (!exportChildNodesHidden)
            {
                exportChildNodesHidden = !treeNode.Expanded && this.CollapsedNodeOption == HiddenOption.ExportAsHidden;
                collapsedParentLevel   = treeNode.Level;
            }
            return(viewSpreadExportRow);
        }