Witam mam pewne pytanko ponieważ siedzę przy c# od niedawna i nie znam jeszcze wielu funkcij i dlatego mam pytanko czy da sie skrocic fragment kodu ktory wklejam ponizej? A jeżeli się da a wydaje mi sie ze sie da to jak to zrobic ?
if (b.Location.X >= 0 && b.Location.X <= 100 && b.Location.Y >= Convert.ToInt32(position[0]) && b.Location.Y <= Convert.ToInt32(position[1])) // 0 to 135
{
b.Location = new Point(50 - (b.Width / 2), 68 - (b.Height / 2));
}
else if (b.Location.X >= 0 && b.Location.X <= 100 && b.Location.Y >= Convert.ToInt32(position[1]) && b.Location.Y <= Convert.ToInt32(position[2])) // 135 to 270
{
b.Location = new Point(50 - (b.Width / 2), 204 - (b.Height / 2));
}
else if (b.Location.X >= 0 && b.Location.X <= 100 && b.Location.Y >= Convert.ToInt32(position[2]) && b.Location.Y <= Convert.ToInt32(position[3])) // 270 to 405
{
b.Location = new Point(50 - (b.Width / 2), 340 - (b.Height / 2));
}
else if (b.Location.X >= 0 && b.Location.X <= 100 && b.Location.Y >= Convert.ToInt32(position[3]) && b.Location.Y <= Convert.ToInt32(position[4])) // 405 to 540
{
b.Location = new Point(50 - (b.Width / 2), 476 - (b.Height / 2));
}
else if (b.Location.X >= 0 && b.Location.X <= 100 && b.Location.Y >= Convert.ToInt32(position[4]) && b.Location.Y <= Convert.ToInt32(position[5])) // 540 to 675
{
b.Location = new Point(50 - (b.Width / 2), 612 - (b.Height / 2));
}
else if (b.Location.X >= 0 && b.Location.X <= 100 && b.Location.Y >= Convert.ToInt32(position[5]) && b.Location.Y <= Convert.ToInt32(position[6])) // 675 to 810
{
b.Location = new Point(50 - (b.Width / 2), 748 - (b.Height / 2));
}