danielsalama
New Coder
I am trying to make an live paint program, what means that the server side will draw something and the client side will get it.
I worked very hard on it for two weeks, and I was only able to make a server side that sends the drawings. I do not know how I can get them from a client side and have them appear on his screen.
here is my server side code that works:
I think I need to convert on the client side the bytes that the server side sends to Point, and I also need to convert the location to Point. And then I can print them on the screen of the client side and there will be a drawing, but I do not know how to do it even after very hard work and a lot of effort. Therefore, I would be very happy if you could help me.
I worked very hard on it for two weeks, and I was only able to make a server side that sends the drawings. I do not know how I can get them from a client side and have them appear on his screen.
here is my server side code that works:
Code:
private void flowLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
if(pen_moving && pen_moving && pen_x != -1 && pen_y != -1)
{
location = e.Location;
draw.DrawLine(my_pen, new Point(pen_x, pen_y), e.Location);
networkStream = client.GetStream();
StreamWriter swr = new StreamWriter(networkStream);
swr.WriteLine(location);
BinaryFormatter binFormatter = new BinaryFormatter();
binFormatter.Serialize(networkStream, sendingdraws());
}
}
private Point sendingdraws()
{
Point toSend = new Point(pen_x, pen_y);
draw.DrawLine(my_pen, new Point(pen_x, pen_y), location);
return toSend;
}
I think I need to convert on the client side the bytes that the server side sends to Point, and I also need to convert the location to Point. And then I can print them on the screen of the client side and there will be a drawing, but I do not know how to do it even after very hard work and a lot of effort. Therefore, I would be very happy if you could help me.