当图形元素比较多时,可以用定时器在CODE前后加上测试计时,可是呈现会滞后很长时间 ,在CODE部分之外,这个该怎么处理?
非常感谢!
sw.Restart();
ChartHelp.JqbDrawStreamGeo(canvas1, linesDataList, Brushes.Red, 5d);
double t2 = sw.ElapsedMilliseconds;
// sw.Stop();
Title += " t2=" + t2.ToString();
public static void JqbDrawStreamGeo(Canvas canvas, List<JqbLinesDataClass> jqbLinesDataList, Brush brush, double strokeThinkness)
{
try
{
Path myPath = new Path();
RenderOptions.SetBitmapScalingMode(myPath , BitmapScalingMode.LowQuality);
myPath.Stroke = brush;
myPath.StrokeThickness = strokeThinkness;
// Create a StreamGeometry to use to specify myPath.
StreamGeometry geometry = new StreamGeometry();
geometry.FillRule = FillRule.EvenOdd;
// Open a StreamGeometryContext that can be used to describe this StreamGeometry
// object's contents.
using (StreamGeometryContext ctx = geometry.Open())
{
for (Int32 i = 0; i < jqbLinesDataList.Count; i++)
{
ctx.BeginFigure(new Point(jqbLinesDataList[i].X1, jqbLinesDataList[i].Y1), true /* is filled */, false /* is closed */);
ctx.LineTo(new Point(jqbLinesDataList[i].X2, jqbLinesDataList[i].Y2), true /* is stroked */, false /* is smooth join */);
}
}
// geometry.Freeze();
// Specify the shape (triangle) of the Path using the StreamGeometry.
myPath.Data = geometry;
canvas.Children.Add(myPath);
myPath.Loaded += new RoutedEventHandler(myPath_Loaded);
}
catch (Exception exc)
{
MessageBox .Show (exc.ToString());
}
}