示例#1
0
        /// <summary>
        /// create the row header of the data table of the chart
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        private RowHeader CreateRowHeader(Table table)
        {
            RowHeader rowheader        = new RowHeader(table);
            int       startColumnIndex = m_tableData.startcell.columnIndex;
            int       endColumnIndex   = m_tableData.endcell.columnIndex;
            Row       row  = new Row(table);
            Cell      cell = this.CreateNullStringCell(table);

            row.Cells.Add(cell);

            for (int i = startColumnIndex; i <= endColumnIndex; i++)
            {
                Cell tempCell = new Cell(table.Document);
                tempCell.OfficeValueType = "string";
                Paragraph paragraph = new Paragraph(m_document);
                string    content   = ((char)('A' + i - 1)).ToString() + "ĮŠ";
                paragraph.TextContent.Add(new SimpleText(m_document, content));
                tempCell.Content.Add(paragraph);
                row.Cells.Add(tempCell);
            }

            rowheader.RowCollection.Add(row);

            return(rowheader);
        }
示例#2
0
        /// <summary>
        /// build the data table of the chart according to the struct of the cell range
        /// copy the data from the spreadsheet document table according to the cell range
        /// </summary>
        /// <returns>the data table</returns>
        public Table CreateTableFromCellRange()
        {
            if (ChartPlotArea.FirstColumnHasLabels() &&
                ChartPlotArea.FirstLineHasLabels())
            {
                BothHasLabels();
            }

            else if (ChartPlotArea.FirstColumnHasLabels())
            {
                RowHeader rowHeader = CreateRowHeader(table);

                table.RowHeader = rowHeader;

                for (int i = startRowIndex; i < endRowIndex; i++)
                {
                    table.Rows.Add(m_tableData.table.Rows [i]);
                }
            }

            else if (this.ChartPlotArea.FirstLineHasLabels())
            {
                FirstLineLabels();
            }

            else
            {
                NoLabels();
            }

            return(table);
        }
示例#3
0
        internal static void UpdateCellParentStyle(Worksheet grid, Cell cell)
        {
            RowHeader rowhead = grid.RetrieveRowHeader(cell.InternalRow);

            if (rowhead.InnerStyle != null)
            {
                cell.InnerStyle      = rowhead.InnerStyle;
                cell.StyleParentKind = StyleParentKind.Row;
            }
            else
            {
                ColumnHeader colhead = grid.RetrieveColumnHeader(cell.InternalCol);

                if (colhead.InnerStyle != null)
                {
                    cell.InnerStyle      = colhead.InnerStyle;
                    cell.StyleParentKind = StyleParentKind.Col;
                }
                else
                {
                    cell.InnerStyle      = grid.RootStyle;
                    cell.StyleParentKind = StyleParentKind.Root;
                }
            }
        }
示例#4
0
        public void GetByOrdinal()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String
                }
            };

            var f = ValidField;
            var r = new RowInformation(header);

            r.Add(new ColumnInformation(f, 0, "cola", false));
            r.Add(new ColumnInformation(ValidField, 1, "colb", false));

            var c = r.Get(0);

            Assert.AreEqual(c.Ordinal, 0);
            Assert.AreEqual(c.Name, "cola");
            Assert.AreEqual(f.Name, c.Field.Name);
            Assert.AreEqual(f.Type, c.Field.Type);
        }
示例#5
0
        string this[int i, bool packaged] {
            get { return(Imports[i]); }
            set {
                string path;
                if (Path.IsPathRooted(value))
                {
                    path = value;
                }
                else
                {
                    packaged = false;
                    path     = "";
                }

                if (i + 1 < this.RowsCount)
                {
                    string text;
                    if (i == Rows.Count - 2)
                    {
                        text = "*";
                    }
                    else
                    {
                        text = i.ToString();
                    }
                    this[i + 1, 0] = new RowHeader(text);                   // add the row number

                    // set the first cell to the glass icon
                    this[i + 1, 1] = new Link(null);
                    SourceGrid2.VisualModels.Common vm = new SourceGrid2.VisualModels.Common();
                    vm.Image                   = glassImg;
                    vm.ImageAlignment          = SourceLibrary.Drawing.ContentAlignment.MiddleCenter;
                    this[i + 1, 1].VisualModel = vm;
                    this[i + 1, 1].Behaviors.Add(new BehaviorEdit());

                    // set the second cell to the delete icon
                    this[i + 1, 2]             = new Link(null);
                    vm                         = new SourceGrid2.VisualModels.Common();
                    vm.Image                   = deleteImg;
                    vm.ImageAlignment          = SourceLibrary.Drawing.ContentAlignment.MiddleCenter;
                    this[i + 1, 2].VisualModel = vm;
                    this[i + 1, 2].Behaviors.Add(new BehaviorDelete());

                    this[i + 1, 3] = new Cell(Path.GetFileName(value), typeof(string)); // add the dll name
                    this[i + 1, 3].Behaviors.Add(new BehaviorFile());                   // add doubleclick functionality

                    this[i + 1, 4] = new Cell(path);                                    // add the dll path
                }
                else
                {
                    this[i + 1, 3].Value = Path.GetFileName(value);
                    this[i + 1, 4].Value = path;
                }

                if (i + 2 < Rows.Count)
                {
                    Imports[i] = value;
                }
            }
        }
        private void DrawRow(RowHeader header, Rect inRect)
        {
            float tW      = inRect.width * 2f;
            float wTxt    = tW * DESC_ROW_T_FRACT;
            float wST     = tW * STORAGE_INFO_FRACT;
            float wButton = BUTTON_FRACT * tW;
            float x0      = inRect.x;
            float x1      = DESC_ROW_T_FRACT * tW + x0;
            float x2      = TEXT_ROW_FRACT * tW + x0;


            var txtHRect = new Rect(inRect)
            {
                width = wTxt
            };
            var stInfoHRect = new Rect(inRect)
            {
                x = x1, width = wST
            };
            var buttonHRect = new Rect(inRect)
            {
                x = x2, width = wButton
            };

            Widgets.Label(txtHRect, header.defHeader);
            Widgets.Label(stInfoHRect, header.totalHeader);
            Widgets.Label(buttonHRect, header.removeHeader);
        }
示例#7
0
        private void OnHeaderLinesBrushPropertyChanged(Brush gridLineBrush)
        {
            ColumnHeader.SetGridLineBrush(gridLineBrush);
            RowHeader.SetGridLineBrush(gridLineBrush);

            Refresh();
        }
示例#8
0
        public MainWindow()
        {
            InitializeComponent();
            Random rnd = new Random();

            for (int i = 0; i < 5; i++)
            {
                Color      randomColor = Color.FromRgb((byte)rnd.Next(i, 256), (byte)rnd.Next(i, 256), (byte)rnd.Next(i, 256));
                EntityView eventEntity = new EntityView(i, $"Событие {i + 1}", randomColor);
                eventListView.Items.Add(eventEntity);
                eventEntityList.Add(eventEntity);
                RowHeader.Add(eventEntity.name);
                ColumnHeader.Add(eventEntity.name);
            }

            eventsRelationships = new EventsRelationships(eventEntityList);

            for (int i = 0; i <= eventEntityList.Count; i++)
            {
                RowDefinition    row    = new RowDefinition();
                ColumnDefinition column = new ColumnDefinition();
                viewTable.ColumnDefinitions.Add(column);
                viewTable.RowDefinitions.Add(row);
            }
        }
示例#9
0
        internal void Initialize(IGridProvider <string> dataProvider)
        {
            if (Points != null)
            {
                Points.PointChanged -= Points_PointChanged;
            }

            Points = new GridPoints(dataProvider.RowCount, dataProvider.ColumnCount, Data.RenderSize);
            Points.PointChanged += Points_PointChanged;

            ColumnHeader.Clear();
            RowHeader.Clear();
            Data.Clear();

            DataProvider = dataProvider;

            _scroller?.StopScroller();
            _scroller = new VisualGridScroller(this);
            Refresh();  // initial refresh

            // reset scroll bar position to zero
            HorizontalScrollBar.Value = HorizontalScrollBar.Minimum;
            VerticalScrollBar.Value   = VerticalScrollBar.Minimum;
            SetScrollBar(ScrollDirection.Both);
        }
示例#10
0
        /// <summary>
        /// Do this action
        /// </summary>
        public override void Do()
        {
            int row   = Range.Row;
            int count = Range.Rows;

            backupRows.Clear();

            int r2 = row + count;

            for (int r = row; r < r2; r++)
            {
                RowHeader rowHead = Worksheet.RetrieveRowHeader(r);

                backupRows.Add(r, new RowHeadData
                {
                    autoHeight = rowHead.IsAutoHeight,
                    row        = rowHead.Row,
                    height     = rowHead.InnerHeight,
                });

                // disable auto-height-adjusting if user has changed height of this row
                rowHead.IsAutoHeight = false;
            }

            Worksheet.SetRowsHeight(row, count, height);
        }
示例#11
0
文件: RptMatrix.cs 项目: Daoting/dt
        public override void WriteXml(XmlWriter p_writer)
        {
            p_writer.WriteStartElement("Matrix");
            WritePosition(p_writer);

            string val = _data.Str("tbl");

            if (val != "")
            {
                p_writer.WriteAttributeString("tbl", val);
            }
            if (HideRowHeader)
            {
                p_writer.WriteAttributeString("hiderowheader", "True");
            }
            if (HideColHeader)
            {
                p_writer.WriteAttributeString("hidecolheader", "True");
            }
            if (RepeatRowHeader)
            {
                p_writer.WriteAttributeString("repeatrowheader", "True");
            }
            if (RepeatColHeader)
            {
                p_writer.WriteAttributeString("repeatcolheader", "True");
            }
            val = _data.Str("rowsort");
            if (val != "")
            {
                p_writer.WriteAttributeString("rowsort", val);
            }
            val = _data.Str("colsort");
            if (val != "")
            {
                p_writer.WriteAttributeString("colsort", val);
            }

            if (Corner != null)
            {
                Corner.WriteXml(p_writer);
            }
            if (RowHeader != null)
            {
                RowHeader.WriteXml(p_writer);
            }
            if (ColHeader != null)
            {
                ColHeader.WriteXml(p_writer);
            }
            if (Rows != null)
            {
                foreach (RptMtxRow row in Rows)
                {
                    row.WriteXml(p_writer);
                }
            }

            p_writer.WriteEndElement();
        }
示例#12
0
        internal static WorksheetRangeStyle FindCellParentStyle(Worksheet sheet, int row, int col, out StyleParentKind pKind)
        {
            RowHeader rowhead = sheet.RetrieveRowHeader(row);

            if (rowhead == null)
            {
                pKind = new StyleParentKind();
                return(new WorksheetRangeStyle());
            }

            if (rowhead.InnerStyle != null)
            {
                pKind = StyleParentKind.Row;
                return(rowhead.InnerStyle);
            }
            else
            {
                ColumnHeader colhead = sheet.RetrieveColumnHeader(col);

                if (colhead.InnerStyle != null)
                {
                    pKind = StyleParentKind.Col;
                    return(colhead.InnerStyle);
                }
                else
                {
                    pKind = StyleParentKind.Root;
                    return(sheet.RootStyle);
                }
            }
        }
示例#13
0
        /// <summary>
        /// Do this operation.
        /// </summary>
        public override void Do()
        {
            Cell cell = Worksheet.CreateAndGetCell(Row, Col);

            this.backupData = cell.HasFormula ? ("=" + cell.InnerFormula) : cell.InnerData;

            this.backupDataFormat     = cell.DataFormat;
            this.backupDataFormatArgs = cell.DataFormatArgs;

            try
            {
                Worksheet.SetSingleCellData(cell, Data);

                var rowHeightSettings = WorksheetSettings.Edit_AutoExpandRowHeight
                                        | WorksheetSettings.Edit_AllowAdjustRowHeight;

                RowHeader rowHeader = this.Worksheet.GetRowHeader(cell.InternalRow);

                this.backupRowHeight = rowHeader.InnerHeight;

                if ((this.Worksheet.settings & rowHeightSettings) == rowHeightSettings &&
                    rowHeader.IsAutoHeight)
                {
                    cell.ExpandRowHeight();
                }
            }
            catch (Exception ex)
            {
                this.Worksheet.NotifyExceptionHappen(ex);
            }
        }
示例#14
0
        private async Task DrawVisualsAsync(GridRange dataViewport, IGridData <string> data, GridUpdateType updateType, Rect visualViewport, bool suppressNotification, CancellationToken token)
        {
            await _services.MainThread().SwitchToAsync(token);

            DataGrid.SelectedIndex = new GridIndex(Math.Min(DataGrid.SelectedIndex.Row, DataProvider.RowCount - 1), Math.Min(DataGrid.SelectedIndex.Column, DataProvider.ColumnCount - 1));
            var columnsData = new RangeToGrid <string>(dataViewport.Columns, data.ColumnHeader, true);
            var rowsData    = new RangeToGrid <string>(dataViewport.Rows, data.RowHeader, false);
            var cellsData   = data.Grid;

            using (Points.DeferChangeNotification(suppressNotification)) {
                // measure points
                ColumnHeader.MeasurePoints(
                    Points.GetAccessToPoints(ColumnHeader.ScrollDirection),
                    new GridRange(new Range(0, 1), dataViewport.Columns),
                    columnsData,
                    updateType);

                RowHeader.MeasurePoints(
                    Points.GetAccessToPoints(RowHeader.ScrollDirection),
                    new GridRange(dataViewport.Rows, new Range(0, 1)),
                    rowsData,
                    updateType == Sort ? Refresh : updateType);

                DataGrid.MeasurePoints(
                    Points.GetAccessToPoints(DataGrid.ScrollDirection),
                    dataViewport,
                    cellsData,
                    updateType == Sort ? Refresh : updateType);

                // adjust Offset in case of overflow
                if ((Points.HorizontalOffset + visualViewport.Width).GreaterOrCloseTo(Points.HorizontalExtent))
                {
                    Points.HorizontalOffset = Points.HorizontalExtent - visualViewport.Width;
                }
                if ((Points.VerticalOffset + visualViewport.Height).GreaterOrCloseTo(Points.VerticalExtent))
                {
                    Points.VerticalOffset = Points.VerticalExtent - visualViewport.Height;
                }

                if (updateType == ScrollIntoView)
                {
                    AdjustFocusedCellOffset(visualViewport);
                }

                // arrange and draw gridline
                ColumnHeader.ArrangeVisuals(Points.GetAccessToPoints(ColumnHeader.ScrollDirection));
                RowHeader.ArrangeVisuals(Points.GetAccessToPoints(RowHeader.ScrollDirection));
                DataGrid.ArrangeVisuals(Points.GetAccessToPoints(DataGrid.ScrollDirection));

                Points.ViewportHeight = DataGrid.RenderSize.Height;
                Points.ViewportWidth  = DataGrid.RenderSize.Width;
            }

            DataViewport = dataViewport;
            Data         = data;
            _owner.AutomationPeer?.Update();
        }
示例#15
0
        /// <summary>
        /// Undo this action
        /// </summary>
        public override void Undo()
        {
            Worksheet.SetRowsHeight(Range.Row, Range.Rows, r => backupRows[r].height, true);

            foreach (int r in backupRows.Keys)
            {
                RowHeader rowHead = Worksheet.RetrieveRowHeader(r);
                rowHead.IsAutoHeight = backupRows[r].autoHeight;
            }
        }
示例#16
0
        public override bool OnMouseUp(Point location, MouseButtons buttons)
        {
            bool isProcessed = false;

            switch (sheet.operationStatus)
            {
            case OperationStatus.AdjustRowHeight:
                if (sheet.currentRowHeightChanging >= 0)
                {
                    SetRowsHeightAction setRowsHeightAction;

                    bool isFullRowSelected = (sheet.selectionMode == WorksheetSelectionMode.Range &&
                                              sheet.selectionRange.Cols == sheet.cols.Count &&
                                              sheet.selectionRange.ContainsRow(sheet.currentRowHeightChanging));

                    RowHeader rowHeader    = sheet.rows[sheet.currentRowHeightChanging];
                    var       delta        = (sheet.headerAdjustNewValue - this.headerAdjustBackup) / scaleFactor;
                    var       targetHeight = (ushort)Math.Max(delta + rowHeader.InnerHeight, 0);

                    if (targetHeight != rowHeader.InnerHeight)
                    {
                        if (isFullRowSelected)
                        {
                            setRowsHeightAction = new SetRowsHeightAction(sheet.selectionRange.Row, sheet.selectionRange.Rows, targetHeight);
                        }
                        else
                        {
                            setRowsHeightAction = new SetRowsHeightAction(sheet.currentRowHeightChanging, 1, targetHeight);
                        }

                        sheet.DoAction(setRowsHeightAction);
                    }

                    sheet.currentRowHeightChanging = -1;
                    sheet.operationStatus          = OperationStatus.Default;
                    this.headerAdjustBackup        = sheet.headerAdjustNewValue = 0;

                    sheet.RequestInvalidate();
                    this.FreeFocus();
                    isProcessed = true;
                }
                break;

            case OperationStatus.FullRowSelect:
            case OperationStatus.FullSingleRowSelect:
                sheet.operationStatus = OperationStatus.Default;
                sheet.controlAdapter.ChangeCursor(CursorStyle.Selection);

                this.FreeFocus();
                isProcessed = true;
                break;
            }

            return(isProcessed);
        }
示例#17
0
        private void OnHeaderBackgroundPropertyChanged(Brush headerBackground)
        {
            ColumnHeader.Background = headerBackground;
            RowHeader.Background    = headerBackground;

            // VisualGrid uses OnRender to paint background color, InvalidateVisual will call it
            ColumnHeader.InvalidateVisual();
            RowHeader.InvalidateVisual();

            Refresh();
        }
示例#18
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = ColumnGroups.GetHashCode();
         result = (result * 397) ^ RowCount;
         result = (result * 397) ^ (RowHeader != null ? RowHeader.GetHashCode() : 0);
         result = (result * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         return(result);
     }
 }
示例#19
0
        public void TheListOfColumnsGivenCannotBeEmpty()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string>(),
                Types   = new List <int>()
            };

            // ReSharper disable once ObjectCreationAsStatement
            Assert.Throws <ArgumentException>(() => new RowInformation(header));
        }
示例#20
0
        static MainTabWindow_ChamberDatabase()
        {
            _cachedHeaders = new RowHeader[2];



            //setup the headers just once
            string totalHeader  = "PMGenebankTotalColumnHeader".Translate();
            string removeHeader = "PMGenebankRemoveColumnHeader".Translate();

            _cachedHeaders[(int)Mode.Animal]    = new RowHeader("PMGeneBankAnimalDefHeader".Translate(), totalHeader, removeHeader);
            _cachedHeaders[(int)Mode.Mutations] = new RowHeader("PMGenebankMutationDefInfoColumnHeader".Translate(), totalHeader, removeHeader);
        }
示例#21
0
        public RSRowObject(Worksheet sheet, RowHeader rowHeader)
        {
            this.sheet     = sheet;
            this.rowHeader = rowHeader;

            this["height"] = new ExternalProperty(
                () => rowHeader.Height,
                (v) => rowHeader.Height = (ushort)ScriptRunningMachine.GetIntValue(v));

            this["visible"] = new ExternalProperty(
                () => rowHeader.IsVisible,
                (v) => rowHeader.IsVisible = ScriptRunningMachine.GetBoolValue(v));
        }
示例#22
0
        /// <inheritdoc />
        public async Task <bool> ReadAsync(CancellationToken cancellationToken)
        {
            var rowHeader = await GetGuiOnlyValueAsync <RowHeader>(SQLiteMessage.ExecuteReaderReadRequest).ConfigureAwait(false);

            _currentRowHeader   = rowHeader;
            _parentCommand.Guid = _currentRowHeader.Guid;

            // we need to reset some field now.
            _dataTypeName.Clear();
            _currentRowInformation = null;

            // if we have no rows, then we have nothing else to read.
            return(rowHeader.HasRows);
        }
        private static void FillHeaders(IList <string> headersText)
        {
            foreach (string headerText in headersText)
            {
                bool isFirst = headerText == "С";

                Header columnHeader = new ColumnHeader(headerText, isFirst);
                Header rowHeader    = new RowHeader(headerText, isFirst);
                Header.IncrementCounter();

                _sourceGrid.Children.Add(columnHeader);
                _sourceGrid.Children.Add(rowHeader);
            }
        }
示例#24
0
        public void FieldTypeObjectWithNoValue()
        {
            var r = new RowHeader {
                HasRows = true,
                Names   = new List <string> {
                    "cola"
                },
                Types = new List <int> {
                    (int)FieldType.Object
                }
            };

            Assert.AreEqual(r.GetType(0), typeof(object));
        }
示例#25
0
文件: RptMatrix.cs 项目: Daoting/dt
        /// <summary>
        /// 生成新的矩阵
        /// </summary>
        /// <returns></returns>
        public override RptItem Clone()
        {
            RptMatrix mtx = new RptMatrix(this.Part);

            mtx._data.Copy(_data);
            mtx.Corner    = Corner.Clone(mtx);
            mtx.ColHeader = ColHeader.Clone(mtx);
            mtx.RowHeader = RowHeader.Clone(mtx);
            foreach (RptMtxRow row in Rows)
            {
                mtx.Rows.Add(row.Clone(mtx));
            }
            return(mtx);
        }
示例#26
0
        public void FieldTypesCannotBeNull()
        {
            var row = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola"
                },
                Types = null
            };

            // ReSharper disable once ObjectCreationAsStatement
            Assert.Throws <ArgumentNullException>(() => new RowInformation(row));
        }
示例#27
0
        public override bool OnMouseMove(Point location, MouseButtons buttons)
        {
            bool isProcessed = false;

            switch (sheet.operationStatus)
            {
            case OperationStatus.Default:
                if (buttons == MouseButtons.None &&
                    sheet.HasSettings(WorksheetSettings.Edit_AllowAdjustRowHeight))
                {
                    int  row    = -1;
                    bool inline = sheet.FindRowByPosition(location.Y, out row);

                    if (row >= 0)
                    {
                        sheet.controlAdapter.ChangeCursor(inline ? CursorStyle.ChangeRowHeight :
                                                          (sheet.selectionMode == WorksheetSelectionMode.None ? CursorStyle.PlatformDefault : CursorStyle.FullRowSelect));
                    }
                }
                break;

            case OperationStatus.AdjustRowHeight:
                if (buttons == MouseButtons.Left &&
                    sheet.currentRowHeightChanging >= 0)
                {
                    RowHeader rowHeader = sheet.rows[sheet.currentRowHeightChanging];
                    sheet.headerAdjustNewValue = location.Y - rowHeader.Top;
                    if (sheet.headerAdjustNewValue < 0)
                    {
                        sheet.headerAdjustNewValue = 0;
                    }

                    sheet.controlAdapter.ChangeCursor(CursorStyle.ChangeRowHeight);
                    sheet.RequestInvalidate();
                    isProcessed = true;
                }
                break;

            case OperationStatus.FullRowSelect:
                sheet.SelectRangeEndByMouse(this.PointToController(location));
                sheet.controlAdapter.ChangeCursor(CursorStyle.FullRowSelect);

                isProcessed = true;
                break;
            }

            return(isProcessed);
        }
示例#28
0
        public void NamesOfColumnsCannotBeEmpty()
        {
            var header = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", ""
                },
                Types = new List <int> {
                    (int)FieldType.Object, (int)FieldType.String
                }
            };

            // ReSharper disable once ObjectCreationAsStatement
            Assert.Throws <ArgumentException>(() => new RowInformation(header));
        }
示例#29
0
        public void TheNumberOfFieldTypesDoesNotMatchTheNumberOfColumnNames()
        {
            var row = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.Object
                }
            };

            // ReSharper disable once ObjectCreationAsStatement
            Assert.Throws <ArgumentException>(() => new RowInformation(row));
        }
示例#30
0
        public void FieldTypeWithNoValue()
        {
            var row = new RowHeader
            {
                HasRows = true,
                Names   = new List <string> {
                    "cola", "colb"
                },
                Types = new List <int> {
                    (int)FieldType.String, (int)FieldType.Object
                }
            };

            Assert.AreEqual(row.GetType(0), typeof(string));
            Assert.AreEqual(row.GetType(1), typeof(object));
        }
示例#31
0
        // Load data
        public void LoadData( Array array )
        {
            //
            this.array = array;

            behavior = new CellBehavior( array );


            // set column and row headers
            FixedRows = 1;
            FixedColumns = 1;

            // Redim the grid
            Redim( array.GetLength( 0 ) + FixedRows, array.GetLength( 1 ) + FixedColumns );

            // Header
            this[0, 0] = new Header( );

            // Column headers
            for ( int i = 1; i < this.ColumnsCount; i++ )
            {
                ColumnHeader header = new ColumnHeader( i.ToString( ) );
                header.EnableSort = false;
                this[0, i] = header;
            }
            // Row headers
            for ( int i = 1; i < this.RowsCount; i++ )
            {
                this[i, 0] = new RowHeader( i.ToString( ) );
            }

            // Data cells
            Type type = array.GetValue( 0, 0 ).GetType( );
            for ( int i = 1, ia = 0; i < this.RowsCount; i++, ia++ )
            {
                for ( int j = 1, ja = 0; j < this.ColumnsCount; j++, ja++ )
                {
                    Cell cell = new Cell( array.GetValue( ia, ja ), type );
                    cell.Behaviors.Add( behavior );
                    this[i, j] = cell;
                }
            }

            Colorize( );
        }