Exemple #1
0
        protected virtual void CreateCell(
            PropertyGridSpreadExportCell cell,
            int currentRowIndex,
            int currentColumnIndex)
        {
            this.spreadExportRenderer.CreateCellSelection(currentRowIndex, currentColumnIndex, currentRowIndex, currentColumnIndex + cell.ColSpan - 1);
            this.spreadExportRenderer.MergeCellSelection();
            PropertyGridSpreadExportContentCell exportContentCell = cell as PropertyGridSpreadExportContentCell;

            if (exportContentCell != null)
            {
                bool flag = false;
                if (!string.IsNullOrEmpty(exportContentCell.FormatString))
                {
                    this.spreadExportRenderer.SetCellSelectionFormat(exportContentCell.FormatString);
                    flag = true;
                }
                if (exportContentCell.Value != null)
                {
                    DataType dataType = new DataTypeConvertor().ConvertToDataType(exportContentCell.Value);
                    switch (dataType)
                    {
                    case DataType.String:
                    case DataType.Other:
                        if (!flag)
                        {
                            this.spreadExportRenderer.SetCellSelectionFormat("@");
                        }
                        this.spreadExportRenderer.SetCellSelectionValue(exportContentCell.Text);
                        break;

                    default:
                        this.spreadExportRenderer.SetCellSelectionValue(dataType, exportContentCell.Value);
                        break;
                    }
                }
                else if (!string.IsNullOrEmpty(exportContentCell.Text))
                {
                    if (!flag)
                    {
                        this.spreadExportRenderer.SetCellSelectionFormat("@");
                    }
                    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);
        }
Exemple #2
0
 public PropertyGridSpreadExportCellFormattingEventArgs(
     PropertyGridSpreadExportCell exportCell,
     PropertyGridItemBase item,
     int rowIndex)
 {
     this.exportCell = exportCell;
     this.item       = item;
     this.rowIndex   = rowIndex;
 }
Exemple #3
0
 protected virtual void GetBordersFromVisualCell(
     PropertyGridSpreadExportCell cell,
     LightVisualElement visualCell)
 {
     cell.BorderBoxStyle    = visualCell.BorderBoxStyle;
     cell.BorderColor       = visualCell.BorderColor;
     cell.BorderLeftColor   = visualCell.BorderLeftColor;
     cell.BorderTopColor    = visualCell.BorderTopColor;
     cell.BorderRightColor  = visualCell.BorderRightColor;
     cell.BorderBottomColor = visualCell.BorderBottomColor;
 }
Exemple #4
0
 protected virtual void GetStylesFromVisualCell(
     PropertyGridSpreadExportCell cell,
     LightVisualElement visualCell)
 {
     if (visualCell == null)
     {
         return;
     }
     cell.Font          = visualCell.Font;
     cell.TextAlignment = visualCell.TextAlignment;
     cell.TextWrap      = visualCell.TextWrap;
     cell.BackColor     = this.GetBackColor(visualCell);
     cell.ForeColor     = visualCell.ForeColor;
 }
Exemple #5
0
        private void AddRow(PropertyGridSpreadExportRow row, int currentRowIndex)
        {
            int index1    = 0;
            int rowHeight = -1;

            for (int index2 = 0; index2 < row.Cells.Count; ++index2)
            {
                PropertyGridSpreadExportCell cell = row.Cells[index2];
                if (rowHeight < cell.Size.Height)
                {
                    rowHeight = cell.Size.Height;
                }
                while (this.columnWidths.Count <= index1)
                {
                    this.columnWidths.Add(0);
                }
                if (cell is PropertyGridSpreadExportIndentCell)
                {
                    if (cell.Size.Width > this.columnWidths[index1])
                    {
                        this.columnWidths[index1] = cell.Size.Width;
                        this.spreadExportRenderer.SetWorksheetColumnWidth(index1, (double)cell.Size.Width, false);
                    }
                    this.CreateCell(cell, currentRowIndex, index1);
                }
                else
                {
                    if (rowHeight >= 0)
                    {
                        this.spreadExportRenderer.SetWorksheetRowHeight(currentRowIndex, rowHeight, true);
                    }
                    int num = this.isGridGrouped ? this.depthOfTree + 1 : this.depthOfTree;
                    if (cell.Size.Width > this.columnWidths[index1] && num <= index1)
                    {
                        this.columnWidths[index1] = cell.Size.Width;
                        this.spreadExportRenderer.SetWorksheetColumnWidth(index1, (double)cell.Size.Width, false);
                    }
                    this.CreateCell(cell, currentRowIndex, index1);
                }
                index1 += cell.ColSpan;
            }
        }