コード例 #1
0
ファイル: VisualGrid.cs プロジェクト: JeongPyoHam/Gabang
        private double xPosition(TextVisual visual)
        {
            if (GridType == GridType.RowHeader) {
                return 0.0;
            }

            return Points.xPosition(visual.Column);
        }
コード例 #2
0
ファイル: VisualGrid.cs プロジェクト: JeongPyoHam/Gabang
        private double yPosition(TextVisual visual)
        {
            if (GridType == GridType.ColumnHeader) {
                return 0.0;
            }

            return Points.yPosition(visual.Row);
        }
コード例 #3
0
ファイル: VisualGrid.cs プロジェクト: JeongPyoHam/Gabang
        private void DrawCells(GridRange newViewport, IGrid<string> data)
        {
            var orgGrid = _visualGrid;
            _visualGrid = new Grid<TextVisual>(
                newViewport,
                (r, c) => {
                    if (_dataViewport.Contains(r, c)) {
                        return orgGrid[r, c];
                    }
                    var visual = new TextVisual();
                    visual.Row = r;
                    visual.Column = c;
                    visual.Text = data[r, c];
                    visual.Typeface = Typeface;
                    visual.FontSize = FontSize * (96.0 / 72.0);  // TODO: test in High DPI
                    return visual;
                });

            _visualChildren.Clear();
            foreach (int c in newViewport.Columns.GetEnumerable()) {
                foreach (int r in newViewport.Rows.GetEnumerable()) {
                    var visual = _visualGrid[r, c];

                    double width = Points.GetWidth(c) - GridLineThickness;
                    double height = Points.GetHeight(r) - GridLineThickness;
                    if (visual.Draw(new Size(width, height))) {
                        Points.SetWidth(c, Math.Max(width, visual.Size.Width + GridLineThickness));
                        Points.SetHeight(r, Math.Max(height, visual.Size.Height + GridLineThickness));
                    }

                    _visualChildren.Add(_visualGrid[r, c]);
                }
            }

            foreach (int c in newViewport.Columns.GetEnumerable()) {
                foreach (int r in newViewport.Rows.GetEnumerable()) {
                    var visual = _visualGrid[r, c];

                    var transform = visual.Transform as TranslateTransform;
                    if (transform == null) {
                        visual.Transform = new TranslateTransform(xPosition(visual), yPosition(visual));
                    } else {
                        transform.X = xPosition(visual);
                        transform.Y = yPosition(visual);
                    }
                }
            }
            _dataViewport = newViewport;

            // special handling for Row/Column header's size: this will layout system (measure/arrange) to know the size of component properly.
            if (GridType == GridType.ColumnHeader && RowCount > 0) {
                Height = Points.GetHeight(0);
            } else if (GridType == GridType.RowHeader && ColumnCount > 0) {
                Width = Points.GetWidth(0);
            }
        }