I am trying to draw a line using user input coordinate in window form application (WFA). The user will input array of points, and then I press the button to draw the connected point (line).
The code is simple and straights forward but I am struggle to image how I can use it in WFA, do I use textbox and insert the code in the textbox code? The following is the structure of the code, that's how I think it should be, any help please?
using System;
namespace Sample
{
class Test
{
public static void Main(string[] args)
{
string testString;
Console.Write("Enter point1 coordinate - ");
point1 = Console.ReadLine();
Console.Write("Enter point2 coordinate - ");
point2 = Console.ReadLine();
}
}
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Pen redPen = new Pen(Color.Red, 1);
PointF[] ptsArray=
{
new PointF(20.0F, 20.0F),
new PointF (20.0F, 20.0F),
new PointF (200.0F, 200.0F),
new PointF (20.0F, 20.0F)
};
e.Graphics.DrawLines (redPen, ptsArray);
//Dispose of objects
redPen.Dispose();
PointF[] ptsArray=
{
new PointF(Console.ReadLine()), // this is an example only
new PointF (20.0F, 20.0F),
new PointF (200.0F, 200.0F),
new PointF (20.0F, 20.0F)
};
e.Graphics.DrawLines (redPen, ptsArray);
}