Inheritance: System.Windows.Media.DrawingVisual
Example #1
0
 private void InitVisual(int r, int c, IGrid <string> data, TextVisual visual)
 {
     visual.Row        = r;
     visual.Column     = c;
     visual.Text       = data[r, c];
     visual.Typeface   = Typeface;
     visual.FontSize   = FontSize; // FontSize here is in device independent pixel, and Visual's FormattedText API uses the same unit
     visual.Foreground = Foreground;
 }
Example #2
0
        internal void MeasurePoints(IPoints points, GridRange newViewport, IGrid <string> data, bool refresh)
        {
            var orgGrid = _visualGrid;

            _visualGrid = new Grid <TextVisual>(
                newViewport,
                (r, c) => {
                if (!refresh && _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;   // FontSize here is in device independent pixel, and Visual's FormattedText API uses the same unit
                visual.Foreground = Foreground;
                return(visual);
            });

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

                    visual.Draw();
                    points.Width[c]  = visual.Size.Width + (visual.Margin * 2) + GridLineThickness;
                    points.Height[r] = visual.Size.Height + (visual.Margin * 2) + GridLineThickness;

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

            _dataViewport = newViewport;
        }
Example #3
0
        private void CreateGrid(GridRange newViewport, IGrid <string> data, GridUpdateType updateType)
        {
            var orgGrid = _visualGrid;

            if (Header)
            {
                _visualGrid = new Grid <TextVisual>(
                    newViewport,
                    (r, c) => {
                    if (updateType == GridUpdateType.Sort)
                    {
                        return(orgGrid[r, c]);
                    }
                    if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c))
                    {
                        return(orgGrid[r, c]);
                    }
                    var visual = new HeaderTextVisual(c);
                    InitVisual(r, c, data, visual);
                    return(visual);
                });
            }
            else
            {
                _visualGrid = new Grid <TextVisual>(
                    newViewport,
                    (r, c) => {
                    if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c))
                    {
                        return(orgGrid[r, c]);
                    }
                    var visual = new TextVisual();
                    InitVisual(r, c, data, visual);
                    return(visual);
                });
            }
        }
Example #4
0
 private void InitVisual(int r, int c, IGrid<string> data, TextVisual visual) {
     visual.Row = r;
     visual.Column = c;
     visual.Text = data[r, c];
     visual.Typeface = Typeface;
     visual.FontSize = FontSize; // FontSize here is in device independent pixel, and Visual's FormattedText API uses the same unit
     visual.Foreground = Foreground;
 }
Example #5
0
 private void CreateGrid(GridRange newViewport, IGrid<string> data, GridUpdateType updateType) {
     var orgGrid = _visualGrid;
     if (Header) {
         _visualGrid = new Grid<TextVisual>(
                 newViewport,
                 (r, c) => {
                     if (updateType == GridUpdateType.Sort) {
                         return orgGrid[r, c];
                     }
                     if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c)) {
                         return orgGrid[r, c];
                     }
                     var visual = new HeaderTextVisual(c);
                     InitVisual(r, c, data, visual);
                     return visual;
                 });
     } else {
         _visualGrid = new Grid<TextVisual>(
             newViewport,
             (r, c) => {
                 if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c)) {
                     return orgGrid[r, c];
                 }
                 var visual = new TextVisual();
                 InitVisual(r, c, data, visual);
                 return visual;
             });
     }
 }
Example #6
0
        internal void MeasurePoints(IPoints points, GridRange newViewport, IGrid<string> data, bool refresh) {
            var orgGrid = _visualGrid;
            _visualGrid = new Grid<TextVisual>(
                newViewport,
                (r, c) => {
                    if (!refresh && _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; // FontSize here is in device independent pixel, and Visual's FormattedText API uses the same unit
                    visual.Foreground = Foreground;
                    return visual;
                });

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

                    visual.Draw();
                    points.Width[c] = visual.Size.Width + (visual.Margin * 2) + GridLineThickness;
                    points.Height[r] = visual.Size.Height + (visual.Margin * 2) + GridLineThickness;

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

            _dataViewport = newViewport;
        }