如何在列表中添加线坐标,然后使用它们再次绘制线?

how can I add Line coordinates in a list and then use them to draw lines again?

这就是我正在尝试的:

private List liLines = new List<int>;
CDrawer can = new CDrawer(800, 800);
public void Form1_Load(object sender, EventArgs e)
{
    can.MouseLeftClick += new GDIDrawerMouseEvent(Can_MouseLeft);
    can.MouseRightClick += new GDIDrawerMouseEvent(Can_MouseRight);
    System.Threading.Thread.Sleep(50);            
}

void DrawLineItem()
{           
    can.AddLine(X1, Y1, X2, Y2, Color.White, 5);
    liLines.Add(new DrawLineItem(X1, Y1, X2, Y2));
}

请help.Thank你

臀部射击(仅限基础):定义

  • class Coord { public double X; public double Y; Coord(double x, double y) { X = x; Y = y; } }
  • class Line { public Coord P1; public Coord P2; Line(Coord p1, Coord p2) { P1 = p1; P2 = p2; } }

那么你可以使用var lines = new List<Line>()
然后做 lines.Add(new Line(new Coordinate(1,2), new Coordinate(3,4));.