private bool chek(double Diameter, double Lenght) { MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel; string caption = "Error"; double lenght = Lenght; DialogResult result; bool chek = true; for (int i = 0; i <= var_es.feature_list.Count - 1; i++) { Feature n = var_es.feature_list[i]; if (n.GetType().ToString() == "InvAddIn.ring") { if (Diameter / 2 <= n.Radius) { result = MessageBox.Show("One of retailing ring features has wrong radius value, delete this feature?", caption, buttons); if (result == DialogResult.Yes) { addInForm.Delete(); var_es.feature_list.RemoveAt(i); addInForm.nodes.RemoveAt(n.Position); addInForm.NODES[ID].RemoveAt(n.Node_Position); addInForm.buttonTree1.ReLoad(); } else if (result == DialogResult.No) { Ring _ring = new Ring(ID, n.Node_Position, n.Side); _ring.Owner = this; _ring.ShowDialog(); } else { chek = false; return(chek); } } lenght -= n.Distance + n.Width; } else { var x = n as Groove; if (Diameter / 2 <= n.Depth) { result = MessageBox.Show("One of groove features has wrong depth value, delete this feature?", caption, buttons); if (result == DialogResult.Yes) { addInForm.Delete(); var_es.feature_list.RemoveAt(i); addInForm.nodes.RemoveAt(n.Position); addInForm.NODES[ID].RemoveAt(n.Node_Position); addInForm.buttonTree1.ReLoad(); } else if (result == DialogResult.No) { groove _groove = new groove(ID, n.Node_Position, n.Side); _groove.Owner = this; _groove.ShowDialog(); } else { chek = false; return(chek); } } lenght -= n.Distance + x.Hord; } if (lenght <= 0) { result = MessageBox.Show("Summ of all features lenght is higher than lenght of figure you need to fix this before decresing figure lenght", caption, MessageBoxButtons.OK); if (result == DialogResult.OK) { chek = false; return(chek); } } } return(chek); }