private void HandleLostFocus(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Text)) { CustomaryLength.TryParse(Text, out CustomaryLength? parsedValue); if (parsedValue.HasValue) { Text = parsedValue.Value.ToFractionalInchString(_denominator); Font = _normalFont; BackColor = Colors.GoodBackground; ForeColor = Colors.GoodForeground; } else { Font = _errorFont; BackColor = Colors.BadBackground; ForeColor = Colors.BadForeground; } } else { Font = _normalFont; BackColor = Colors.NeutralBackground; ForeColor = Colors.NeutralForeground; } }
public double?GetRawValue() { if (CustomaryLength.TryParse(Text, out CustomaryLength? result)) { return(result.Value.DecimalInches); } else { return(null); } }