可以使用DrawLines方法绘制的行数

时间:2014-02-10 18:11:20

标签: vb.net visual-studio-2012 graph system.drawing

我使用DrawLines方法在PrintPreviewControl上绘制一系列线条。这是我的代码,我在其中获取x和y值并将它们转换为页面矩形内的坐标,将它们添加到列表中。然后我用笔调用DrawLines并将列表转换为数组。我发现DrawLines只使用8126个点对绘制8125行。 DrawLines失败时我没有收到任何异常。有没有办法增加DrawLines将使用的点对数?或者,我可以单独绘制每一行,或者我可以将点数组解析为8000点块。

Private Sub DrawGammaLog(ByVal gr As Graphics)
  Try
    'draw log in chart area
    If Points.Count <> 0I Then
      gr.SetClip(LogRect)
      Dim LPoints As New List(Of PointF)
      For Each pt In Points
        Dim PointY As Single = LogRect.Top + ((pt.Depth - VScaleMinValue) * VScale)
        Dim PointX As Single = LogRect.Left + (pt.Count * HScale)
        If PointY >= LogRect.Top AndAlso PointY <= LogRect.Bottom Then
          LPoints.Add(New PointF(PointX, PointY))
        End If
      Next
      Debug.Print("{0}", LPoints.Count)
      If LPoints.Count >= 2I Then gr.DrawLines(gpp.LogPen, LPoints.ToArray)
    End If
    'draw box around chart area
    gr.DrawRectangle(gpp.LogPen, Rectangle.Round(LogRect))
  Catch ex As Exception
    MessageBox.Show(ex.Message.ToString & ", " & ex.Source.ToString, Me.Text & " DrawGammaLog")
  Finally
    gr.ResetClip()
  End Try
End Sub

1 个答案:

答案 0 :(得分:0)

此处在Visual Studio 2010中使用c#发生同样的问题。8125似乎是限制,即使在线没有对此问题的引用...

我已将我的数组拆分为8000 PointF []数组块,作为解决方法。

int counter = 0;
int block_size = Math.Min(data.Length, 8000);
PointF[] data_subset;

while (counter != data.Length)
{
    data_subset = new PointF[block_size];
    Array.Copy(data, counter, data_subset, 0, data_subset.Length);
    g.DrawLines(p, data_subset);

    counter += block_size;
    block_size = Math.Min(data.Length - counter, 8000);
}