I have a project for uni which is to make Paint. The part that i can't do is the cut, copy, paste. The user is drawing in a PicureBox and in the PicuteBox MouseDown,Move,Up events is the code which allows the user to draw. If i try to put a code for rubber band box in these events it doesn't work. I tried creating a selection item in the MenuStrip i use and use the selection MouseMove,Down,Up events, but it doesn't work. The user should be able to draw something or upload a picture and when he press that selection button to mark the part of the drawing or the picture he wants to cut, copy or paste. I'm still a beginner, so sorry if my question is not well explained or the code is not correct.
public partial class Form1 : Form
{
int x = -1;
int y = -1;
Graphics g;
Pen pen;
public Form1()
{
InitializeComponent();
g = pictureBox1.CreateGraphics();
pen = new Pen(Color.Black, 5);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
startPaint = true;
x = e.X;
y = e.Y;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (startPaint && x != -1 && y != -1)
{
g.DrawLine(pen, new Point(x, y), e.Location);
x = e.X;
y = e.Y;
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
startPaint = false;
x = -1;
y = -1;
}