mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-14 02:26:50 -07:00
Check for valid input in min/max/step fields (#1270)
This commit is contained in:
parent
2104059f72
commit
4c8e1cb5f0
2 changed files with 23 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue