캔버스 요소에 좌표계를 만들었습니다. 나는 모든 가치에 대해 빨간 점을 그리고 그것을 오래된 점과 연결한다.WPF 좌표계 업데이트
는 여기를 참조하십시오 : 나는 매 초마다 약 10 값을 받고 있어요
. = 1 개 픽셀
빨간색 선
1 값은 그냥 테스트를 위해 상수 값을 받고 있어요, 값을 나타냅니다.
내 목표는 좌표계의 끝에 도달하면 도면을 업데이트하는 것입니다. 내 그림을 왼쪽으로 밀고 다음 점을 그립니다.
내 목표는 다음과 같습니다
- 나중에 내가 확대를 원하기 때문에 내 그래프에 포인트를 잃고 밖으로 싶지 않는
- 나는 가능한 한 덜으로 내 시스템을 느리게 돼요 ...
이 내 코드가 아니라 내가 끝 부분의 그래프를 업데이트 할 수 있습니다 방법을 잘 ....입니다
static double xOld = 32;
static double yOld = 580;
static double t = 32;
System.Windows.Shapes.Path path;
static GeometryGroup lineGroupDrw1 = new GeometryGroup();
....
public void drawPoly(double value)
{
//increase point position
t++;
//generate 2 point for the connection
Point pOne = new Point(xOld, yOld);
Point pTwo = new Point(t, value);
//connect old point with new
GeometryGroup lineGroup = new GeometryGroup();
LineGeometry connectorGeometry = new LineGeometry();
connectorGeometry.StartPoint = pOne;
connectorGeometry.EndPoint = pTwo;
lineGroup.Children.Add(connectorGeometry);
path = new System.Windows.Shapes.Path();
path.Data = lineGroup;
path.StrokeThickness = 1;
path.Stroke = path.Fill = Brushes.Red;
//fill the static linegroup with a new point
lineGroupDrw1.Children.Add(connectorGeometry);
if (coordinateSystem.Width > t)
{
// draw graph
coordinateSystem.Children.Add(path);
}
else
{
//To do : update drawing
updateDrawingEnd();
}
//refresh values
xOld = t;
yOld = value;
}
....
public void updateDrawingEnd()
{
path = new System.Windows.Shapes.Path();
path.Data = lineGroupDrw1;
path.StrokeThickness = 1;
path.Stroke = path.Fill = Brushes.Yellow;
coordinateSystem.Children.Add(path);
t = 145;
}
전체 코드 및 XAML을 게시하십시오. –