Hey ,
I am making drawing on bitmap images ,In drawings I've included only rectangles . I want to move all my rectangles together as a group . Can anyone help me regarding this ?
What I have tried:
String data = "";
Font font = new Font("Arial", 14);
Rectangle rect = new Rectangle();
rect.Size = new Size(280, 190);
for (int x = 0; x < 1; x++)
{
rect.X = x * (rect.Width + 45) + 380;
for (int y = 0; y < 1; y++)
{
rect.Y = y * (rect.Height + 35) + 25;
listRec.Add(rect);
data = rect.ToString();
TextWriter txt = new StreamWriter("E:\\Blisters.txt", true);
txt.WriteLine(data);
txt.Close();
}
}
foreach (Rectangle rec in listRec)
{
g = pictureBox1.CreateGraphics();
Pen p = new Pen(Color.Red, 3);
g.DrawRectangle(p, rec);
g.DrawString("B2", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 60, 25);
}
rect.Size = new Size(40, 65);
for (int x = 0; x < 3; x++)
{
rect.X = x * (rect.Width + 30) + 463;
for (int y = 0; y < 2; y++)
{
rect.Y = y * (rect.Height + 35) + 38;
listRec.Add(rect);
data = rect.ToString();
TextWriter txt = new StreamWriter("E:\\B2Pockets.txt", true);
txt.WriteLine(data);
txt.Close();
}
}
foreach (Rectangle rec in listRec)
{
g = pictureBox1.CreateGraphics();
Pen p = new Pen(Color.Red, 3);
g.DrawRectangle(p, rec);
g.DrawString("p1", font, new SolidBrush(Color.Yellow), (rect.Width + 420), 35);
g.DrawString("p2", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 450, 35);
g.DrawString("p3", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 520, 35);
g.DrawString("p4", font, new SolidBrush(Color.Yellow), (rect.Width + 420), (rect.Height + 30) + 40);
g.DrawString("p5", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 450, (rect.Height + 30) + 40);
g.DrawString("p6", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 520, (rect.Height + 30) + 40);
}
I've tried above code.Rectangles drawn successfully. But they can't be move.