/// <summary> /// Пересчёт поля Value по Text. /// </summary> /// <param name="IsOnLostFocus"> /// Происходит ли вызов функции при потере фокуса или нет /// </param> /// <returns></returns> public enCaclValueResult CalcValue(bool IsOnLostFocus = true) { enCaclValueResult result = enCaclValueResult.NoError; float FloatVal = 0; double DoubleVal = 0; int IntVal = 0; switch (InputCheckType) { case enInputCheckType.Float: if (!GlobalDefines.CheckFloat(Text, out FloatVal)) { result = enCaclValueResult.InputCheckError; } Value = FloatVal; break; case enInputCheckType.FloatOrEmpty: if (!GlobalDefines.CheckFloatOrEmpty(Text, out FloatVal)) { result = enCaclValueResult.InputCheckError; } Value = FloatVal; break; case enInputCheckType.NotNegativeFloat: if (!GlobalDefines.CheckNotNegativeFloat(Text, out FloatVal)) { result = enCaclValueResult.InputCheckError; } Value = FloatVal; break; case enInputCheckType.NotNegativeFloatOrEmpty: if (!GlobalDefines.CheckNotNegativeFloatOrEmpty(Text, out FloatVal)) { result = enCaclValueResult.InputCheckError; } Value = FloatVal; break; case enInputCheckType.PositiveFloat: if (!GlobalDefines.CheckPositiveFloat(Text, out FloatVal)) { result = enCaclValueResult.InputCheckError; } Value = FloatVal; break; case enInputCheckType.PositiveFloatOrEmpty: if (!GlobalDefines.CheckPositiveFloatOrEmpty(Text, out FloatVal)) { result = enCaclValueResult.InputCheckError; } Value = FloatVal; break; case enInputCheckType.Double: if (!GlobalDefines.CheckDouble(Text, out DoubleVal)) { result = enCaclValueResult.InputCheckError; } Value = DoubleVal; break; case enInputCheckType.Int: if (!GlobalDefines.CheckInt(Text, out IntVal)) { result = enCaclValueResult.InputCheckError; } Value = IntVal; break; case enInputCheckType.PositiveInt: if (!GlobalDefines.CheckPositiveInt(Text, out IntVal)) { result = enCaclValueResult.InputCheckError; } Value = IntVal; break; case enInputCheckType.NotNegativeInt: if (!GlobalDefines.CheckNotNegativeInt(Text, out IntVal)) { result = enCaclValueResult.InputCheckError; } Value = IntVal; break; case enInputCheckType.NotNegativeIntOrEmpty: if (!GlobalDefines.CheckNotNegativeIntOrEmpty(Text, out IntVal)) { result = enCaclValueResult.InputCheckError; } Value = IntVal; break; case enInputCheckType.Time: Value = Text; break; case enInputCheckType.TimeZeroTimeAllowed: Value = Text; break; case enInputCheckType.TimeOrEmpty: Value = Text; break; case enInputCheckType.NotEmpty: if (string.IsNullOrWhiteSpace(Text)) { result = enCaclValueResult.InputCheckError; } Value = Text; break; default: Value = Text; break; } if (IsOnLostFocus && AdditionalRightInputCond != null && result == enCaclValueResult.NoError && !AdditionalRightInputCond(this)) { result = enCaclValueResult.AdditionalCondError; } return(result); }