Im trying to create easy drawing program in Visual Studio 2015 (c#). It just about drawing lines to create some kind of shape. In forst Form i draw shapes, and i want to copy this shape to another Form where i can work on it (do some math with it). The problem is i dont know how to copy created shape (and all other data) to second Form.
Could you help me?
public partial class Form1 : Form
{
Form2 secondForm = new Form2();
Graphics gObject;
Brush BBrush = new SolidBrush(Color.Black);
Pen BPen = new Pen(Color.Black, 2);
int xs = 100, ys = 100; //starting points
int move;
int xt = 0, yt = 0; // temporary points
public void button1_Click(object sender, EventArgs e)
{
if (xt == 0 & yt ==0)
{
gObject.DrawLine(BPen, xs, ys, xt = xs + move, ys);
secondForm.xs = xs;
secondForm.ys = ys;
secondForm.xt = xt;
secondForm.yt = yt;
secondForm.move = move;
// Draw same line in second Form
secondForm.gObject = secondForm.DrawingPanel.CreateGraphics();
secondForm.gObject.DrawLine(BPen, xs, ys, xt = xs + move, ys);
}