Beispiel #1
0
        protected virtual void CreateImageOverCell(
            TreeViewSpreadExportImageCell cell,
            int currentRowIndex,
            int currentColumnIndex)
        {
            if (cell.Image == null)
            {
                return;
            }
            int offsetX = 0;
            int offsetY = 0;

            if (cell.ImageAlignment.ToString().Contains("Middle"))
            {
                offsetY = (cell.Size.Height - cell.Image.Height) / 2;
            }
            else if (cell.ImageAlignment.ToString().Contains("Bottom"))
            {
                offsetY = cell.Size.Height - cell.Image.Height;
            }
            Image image = cell.Image;

            byte[] byteArray = this.ConvertImageToByteArray(image);
            this.spreadExportRenderer.CreateFloatingImage(currentRowIndex, currentColumnIndex, offsetX, offsetY, byteArray, "png", image.Width, image.Height, 0);
        }
Beispiel #2
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 #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);
        }