0

I need a WPF Control with 300000000 Width and Height, on which I will draw Rectangles, based on some input. I am drawing the Rectangle on the OnRender of the control. For testing purpose I have put the control inside a ScrollViewer and am drawing Rectangles on each pixels from (0,0) to (1000,1000). If the Width & Height is 1000000, the Rectangles are drawn properly, shown below, (the Rectangles are plotted on all the pixels from (0,0) to (1000,1000), so it looks like the on in the below link)

https://social.msdn.microsoft.com/Forums/getfile/950012

But If I increase the size to 3000000, few lines are missing in the drawing like below, https://social.msdn.microsoft.com/Forums/getfile/950018

My Xaml:

<ScrollViewer x:Name="MainScrollViewer"
              Grid.Row="2"
              Grid.ColumnSpan="2"
              HorizontalScrollBarVisibility="Auto"
              VerticalScrollBarVisibility="Auto">
  <waferControl:WaferMapControl x:Name="WaferControl"
                                Grid.Row="2"
                                Grid.ColumnSpan="2"
                                Width="30000000"
                                Height="30000000"
                                Margin="10"
                                ColumnCount="{Binding WaferInfo.ColumnCount}"
                                RowCount="{Binding WaferInfo.RowCount}"
                                SelectedCells="{Binding SelectedCellCollection}"
                                Visibility="Collapsed" />
</ScrollViewer>

I am using the following code in OnRender of WaferMapControl.

private void RenderBackgroud(IEnumerable lists`enter code here`)
{
    using (DrawingContext dc = _backgroundDv.RenderOpen())
    {
        SolidColorBrush brush = Brushes.Black;

        if (brush.CanFreeze)
            brush.Freeze();

        foreach (GridCellInfo cellInfo in lists)
        {
            double length = cellInfo.GridRange;

            var point = new Point(
                cellInfo.RowIndex + 1,
                ActualHeight - cellInfo.ColumnIndex  - length);

            RenderBackgroud(dc, point, brush, length);
        }
    }
}

private void RenderBackgroud(DrawingContext dc, Point point, Brush brush, double length)
{
   var rect = new Rect(point, new Size(length, length));

   dc.DrawRectangle(brush, null, rect);
} 

The cellInfo contains the x,y coordinates. The point calculation is done to draw from the bottom left. The length is 1 in my sample.

Can someone help me out, what is the issue here. Let me know if you require anything from my side.

Massimiliano Kraus
  • 3,638
  • 5
  • 27
  • 47
Hemanath
  • 19
  • 4
  • do you have a full reproducing code? – Simon Mourier Oct 18 '16 at 06:01
  • then please share it – Simon Mourier Oct 18 '16 at 06:07
  • Perhaps this is being caused by antialiasing. Try turning it off (something like `this.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased)` before looping to draw the rectangles) – Matthew Watson Oct 18 '16 at 06:37
  • @MatthewWatson not working. still the same. – Hemanath Oct 18 '16 at 06:50
  • @SimonMourier you can download the code from [here](https://1drv.ms/u/s!Aout7a-ZRaxMiiiDpckw_lIvsYnN) – Hemanath Oct 18 '16 at 10:19
  • My guess is it's 100% by design. Since you always displays the same number of rows with a rectangle of 1 pixel high per row (like a line), if you stretch the control vertically, it will just stretch the space between the rectangles/lines. – Simon Mourier Oct 18 '16 at 17:09
  • @SimonMourier I dont think that would be the issue as the Control size is increased both vertically and horizontally. And also it does not work only if the size is increased beyond 10000000. – Hemanath Oct 19 '16 at 07:49

0 Answers0