Exemplo n.º 1
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);
        }