示例#1
0
        private void CreateVisualChildren()
        {
            //this.Width = this.m_colWidths.Count * 30;
            //this.Height = this.m_rowHeights.Count * 10;
            this.Width = 0;
            this.Height = 0;

            for (int _row = 0; _row < this.m_rowHeights.Count; _row++)
            {
                this.Height += this.m_rowHeights[_row];

                for (int _col = 0; _col < this.m_colWidths.Count; _col++)
                {
                    Cell _cell = new Cell()
                        {
                            Row = _row,
                            Column = _col
                        };

                    DrawingContext _drawing = _cell.RenderOpen();

                    _drawing.DrawRectangle(
                        Brushes.White,
                        new Pen(Brushes.Black, 0.1),
                        new Rect(
                            _col * this.m_colWidths[_col],
                            _row * this.m_rowHeights[_row],
                            (this.m_colWidths[_col] - 4),
                            (this.m_rowHeights[_row] - 4)
                            )
                        );

                    _drawing.DrawText(
                        new FormattedText(
                            _table.Rows[_row][_col].ToString(),
                            CultureInfo.GetCultureInfo("en-us"),
                            FlowDirection.LeftToRight,
                            new Typeface("Verdana"),
                            8,
                            Brushes.Black),
                        new Point(_col * this.m_colWidths[_col], _row * this.m_rowHeights[_row])
                     );

                    _drawing.Close();

                    if (_row == 0)
                    {
                        this.Width += this.m_colWidths[_col];
                    }
                    this.m_visualChildren.Add(_cell);
                }
            }
        }