a small question here where I didn't find a proper answer to. I want to save a drawn location of a Ellipse so I can later on draw a line between 2 ellipses, so I want to save this as a point if this is possible.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
screen.Clear(Color.Black);
using (var p = new Pen(Color.White, 2))
{
for (int x = 0; x < p1List.Count; x++)
{
screen.DrawLine(p, p1List[x], p2List[x]);
}
}
List<Point> punten = new List<Point>();
foreach (var pair in this.droppedShapes)
{
var shapeType = pair.Item2; // Reveal your own shape object here
var location = pair.Item1;
switch (shapeType) // Reveal your own shape object here
{
case 0:
screen.DrawRectangle(whitePen, location.X - 10, location.Y - 10, 40, 40);
screen.DrawString("&", new Font(FontFamily.GenericMonospace, (float)28), whiteBrush, location.X - 11, location.Y - 13);
//input
screen.DrawLine(whitePen, location.X - 25, location.Y, location.X - 10, location.Y );
screen.FillEllipse(greenBrush, location.X - 30, location.Y - 5, 10, 10);
punten.Add(); //add the location of the "ellipse"
//input
screen.DrawLine(whitePen, location.X - 25, location.Y + 20, location.X - 10, location.Y + 20);
screen.FillEllipse(greenBrush, location.X - 30, location.Y + 15, 10, 10);
//output
screen.DrawLine(whitePen, location.X + 30, location.Y + 10, location.X + 45, location.Y + 10);
screen.FillEllipse(greenBrush, location.X + 40, location.Y + 5, 10, 10);
I already added the line "punten.Add()" because this is the line where I want to save the location. If there is a better way, hit me up!
It seems alright to me, just replace your
punten.Add();
with
punten.Add(new Point(location.X, location.Y));
or something similar for drawing the lines between the locations. Be aware that this will only add Points to your list, if the case 0 in the switch statement is hit, otherwise your List may not contain any Points (or you add Points to the list in the other case sections).