2

所以,基本上我试图在两个椭圆的中心之间画一条线

我认为应该这样做:

Path myPath = new Path();
myPath.Stroke = System.Windows.Media.Brushes.Black;     
myPath.StrokeThickness = 4;
myPath.HorizontalAlignment = HorizontalAlignment.Left;
myPath.VerticalAlignment = VerticalAlignment.Center;
EllipseGeometry myEllipseGeometry = new EllipseGeometry();
myEllipseGeometry.Center = new System.Windows.Point((xQuard * 10) + 100, yQuard * 10);
myEllipseGeometry.RadiusX = 2;
myEllipseGeometry.RadiusY = 2;
myPath.Data = myEllipseGeometry;
GraphPanel.Children.Add(myPath);

//if it's not the first point...
if (prevA != 0.0)
{
Path iLine = new Path();
iLine.Stroke = Brushes.Black;
iLine.StrokeThickness = 4;
iLine.HorizontalAlignment = HorizontalAlignment.Left;
myPath.VerticalAlignment = VerticalAlignment.Center;
LineGeometry iLineGeometry = new LineGeometry();

iLineGeometry.StartPoint = myEllipseGeometry.Center;

iLineGeometry.EndPoint = new System.Windows.Point(prevA, prevB);

iLine.Data = iLineGeometry;
GraphPanel.Children.Add(iLine);

}

//Set the previous point(s)
prevA = (xQuard * 10) + 100;
prevB = yQuard * 10;

现在如您所见,我已将 Line 的 StartPoint = 设置为第一个椭圆起点

但是.... 在此处输入图像描述

为什么图中Line的起点不是左边点的中心?

4

1 回答 1

3

我想你的意思iLine.VerticalAlignment不是myPath.VerticalAlignment第二次,对吧?

于 2012-06-27T14:53:53.630 回答