/// <summary> /// Set figure parameters /// </summary> /// <returns>true если операция прошла успешно; false в случае ошибки</returns> private bool SetFigureParameters() { try { var screwHatWidth = Convert.ToDouble(ScrewHatWidth.Text); var screwHatInnerDiameter = Convert.ToDouble(this.screwHatInnerDiameter.Text); var screwBaseSmoothWidth = Convert.ToDouble(ScrewBaseSmoothWidth.Text); var screwBaseThreadWidth = Convert.ToDouble(ScrewBaseThreadWidth.Text); var nutHeight = Convert.ToDouble(NutHeight.Text); var nutThreadDiameter = Convert.ToDouble(NutThreadDiameter.Text); var parameters = new List <double>() { screwHatWidth, screwHatInnerDiameter, screwBaseSmoothWidth, screwBaseThreadWidth, nutHeight, nutThreadDiameter }; var validator = new FigureParametersValidator(parameters); if (validator.LastErrorCode != ErrorCodes.OK) { return(false); } if (!validator.Validate()) { var errorCatcher = new UserInputErrorCatcher(); errorCatcher.CatchError(validator.ErrorList); return(false); } _figureParameters = parameters; } catch { MessageBox.Show("Есть несколько пустых или недействительных полей. " + "Пожалуйста, заполните их правильно и попробуйте снова. ", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }
/// <summary> /// Set figure parameters /// </summary> /// <returns>true if operation successful; false in case of error</returns> private bool SetFigureParameters() { try { var screwHatWidth = Convert.ToDouble(ScrewHatWidth.Text); var screwHatInnerDiameter = Convert.ToDouble(ScrewHatInnerDiameter.Text); var screwBaseSmoothWidth = Convert.ToDouble(ScrewBaseSmoothWidth.Text); var screwBaseThreadWidth = Convert.ToDouble(ScrewBaseThreadWidth.Text); var nutHeight = Convert.ToDouble(NutHeight.Text); var nutThreadDiameter = Convert.ToDouble(NutThreadDiameter.Text); var parameters = new List <double>() { screwHatWidth, screwHatInnerDiameter, screwBaseSmoothWidth, screwBaseThreadWidth, nutHeight, nutThreadDiameter }; var validator = new FigureParametersValidator(parameters); if (validator.LastErrorCode != ErrorCodes.OK) { return(false); } if (!validator.Validate()) { var errorCatcher = new UserInputErrorCatcher(); errorCatcher.CatchError(validator.ErrorList); return(false); } _figureParameters = parameters; } catch { MessageBox.Show("There are some empty or invalid fields. Please fill him correctly and try again.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }