Check for valid input in min/max/step fields (#1270)

This commit is contained in:
Pepe Rivera 2020-06-15 14:13:56 -07:00 committed by GitHub
commit 4c8e1cb5f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -9,6 +9,9 @@
namespace CalculatorApp::ViewModel
{
inline constexpr int DefaultMinMaxRange = 10;
public
value struct VariableChangedEventArgs sealed
{
@ -40,6 +43,12 @@ public
{
if (m_variable->Min != value)
{
if (value >= m_variable->Max)
{
m_variable->Max = value + DefaultMinMaxRange;
RaisePropertyChanged("Max");
}
m_variable->Min = value;
RaisePropertyChanged("Min");
}
@ -72,6 +81,12 @@ public
{
if (m_variable->Max != value)
{
if (value <= m_variable->Min)
{
m_variable->Min = value - DefaultMinMaxRange;
RaisePropertyChanged("Min");
}
m_variable->Max = value;
RaisePropertyChanged("Max");
}