0

我正在制作一个程序,该程序涉及在给定的“椭圆”之间绘制线条。当我尝试运行模拟器并且鼠标进入第一个“椭圆”时,我遇到了将椭圆转换为点的异常处理问题。如果推荐的话,我可以用不同的方式来做,我所需要的就是能够在给定的坐标之间画一条线,每个坐标都属于各自的椭圆。帮助?

    Point old;
    List<String> DrawnLines = new List<String>();
    private void CheckPoint(object sender, System.Windows.Input.MouseEventArgs e)
    {

        Point selectedEllipse = (Point)sender;


        if (old.Equals(null))
        {
            old.Equals(sender);
        }
        else
        {
            if (selectedEllipse.Equals(old) == false) 
    //This is a check to make sure that a different point has been hit
            {
                System.Windows.Shapes.Line connectline = new System.Windows.Shapes.Line();
                connectline.Width = 10;
                connectline.X1 = old.X;
                connectline.Y1 = old.Y;
                connectline.X2 = selectedEllipse.X; //.Margin.Left;
                connectline.Y2 = selectedEllipse.Y; //.Margin.Top;
                drawCanvas.Children.Add(connectline);
                DrawnLines.Add((old.ToString() + " " + selectedEllipse.ToString()));
                DrawnLines.Add((selectedEllipse.ToString() + " " + old.ToString()));
                old = (Point)sender;
            }
        }
    }
4

0 回答 0