private void pictureBox_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
int? rectangleAtMouse = GetRectangleAt(e.Location);
if (rectangleAtMouse != null)
SelectedIndex = rectangleAtMouse.Value;
RedrawViewImage();
}