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

我认为应该这样做:

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 =设置为第一个椭圆起点

但是....


为什么线的起点在图片中不是左点的中心?

最佳答案

我认为您是第二次使用iLine.VerticalAlignment而不是myPath.VerticalAlignment,对吗?

关于c# - 线条形状和雪茄,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11228879/

10-11 16:19