anastasia.filipova
Member
@jmcilhinney , @Skydiver , @Sheepings
Can I ask a question for which I have a code, but I don't like how it works аnd I would like to improve it. It is about deleting the already drawn figures. Because every time I have to press the "Remove" button before selecting the shape I want to delete. Is there a way to mark several shapes instead of individually as I did?
///
///
Can I ask a question for which I have a code, but I don't like how it works аnd I would like to improve it. It is about deleting the already drawn figures. Because every time I have to press the "Remove" button before selecting the shape I want to delete. Is there a way to mark several shapes instead of individually as I did?
C#:
private List<Shapes> _shapes = new List<Shapes>();
private Shapes _s = null;
private bool optionMove = false;
private bool optionRemove = false;
private bool optionCalculate = false;
///
C#:
private void removeBtn_Click(object sender, EventArgs e)
{
label1.Text = "Click on shape to remove it.";
optionMove = false;
optionRemove = true;
optionCalculate = false;
Form2.triangle = false;
Form2.rectangle = false;
Form2.circle = false;
///
C#:
if (e.Button == MouseButtons.Left)
{
_s = _shapes.Where(shape => shape.ConteinsCordinate(e.Location)).FirstOrDefault();
if (optionRemove == true)
{
_shapes.RemoveAll(removeshape => removeshape.ConteinsCordinate(e.Location));
Invalidate();
}
optionRemove = false;
}