Ejemplo n.º 1
0
        protected virtual void CreateCell(
            TreeViewSpreadExportCell cell,
            int currentRowIndex,
            int currentColumnIndex)
        {
            this.spreadExportRenderer.CreateCellSelection(currentRowIndex, currentColumnIndex, currentRowIndex, currentColumnIndex + cell.ColSpan - 1);
            if (cell.ColSpan > 1)
            {
                this.spreadExportRenderer.MergeCellSelection();
            }
            TreeViewSpreadExportContentCell exportContentCell = cell as TreeViewSpreadExportContentCell;

            if (exportContentCell != null)
            {
                if (!string.IsNullOrEmpty(exportContentCell.FormatString))
                {
                    this.spreadExportRenderer.SetCellSelectionFormat(exportContentCell.FormatString);
                }
                if (exportContentCell.Value != null)
                {
                    this.spreadExportRenderer.SetCellSelectionValue(new DataTypeConvertor().ConvertToDataType(exportContentCell.Value), exportContentCell.Value);
                }
                else if (!string.IsNullOrEmpty(exportContentCell.Text))
                {
                    this.spreadExportRenderer.SetCellSelectionValue(exportContentCell.Text);
                }
                object cellSelectionValue = this.spreadExportRenderer.GetCellSelectionValue();
                if (cellSelectionValue is DateTime && !this.CheckDateTimeValue((DateTime)cellSelectionValue))
                {
                    throw new FormatException("The DateTime value is not supported in Excel!");
                }
            }
            if (!this.ExportVisualSettings && this.CellFormatting == null)
            {
                return;
            }
            if (cell.Font == null)
            {
                cell.Font = Control.DefaultFont;
            }
            this.spreadExportRenderer.CreateCellStyleInfo(cell.BackColor, cell.ForeColor, cell.Font.FontFamily, (double)cell.Font.Size, cell.Font.Bold, cell.Font.Italic, cell.Font.Underline, cell.TextAlignment, cell.TextWrap, cell.BorderBoxStyle, cell.BorderColor, cell.BorderTopColor, cell.BorderBottomColor, cell.BorderRightColor, cell.BorderLeftColor);
        }
Ejemplo n.º 2
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);
        }