port from perforce
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Intromat.Nodes.Code;
|
||||
using Intromat.Views.Editors;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
|
||||
namespace Intromat.ViewModels.Editors
|
||||
{
|
||||
public class IntegerExpressionEditorViewModel : ExpressionEditorBaseViewModel<int, IntLiteralValue, IntLiteralModel>
|
||||
{
|
||||
private int _maxValue;
|
||||
private int _minValue;
|
||||
|
||||
static IntegerExpressionEditorViewModel()
|
||||
{
|
||||
Locator.CurrentMutable.Register(() => new IntegerExpressionEditorView(), typeof(IViewFor<IntegerExpressionEditorViewModel>));
|
||||
}
|
||||
|
||||
public IntegerExpressionEditorViewModel()
|
||||
{
|
||||
this.WhenAnyValue(vm => vm.CustomValue)
|
||||
.Subscribe(newValue =>
|
||||
{
|
||||
if (newValue > MaxValue)
|
||||
{
|
||||
var delta = newValue - MinValue;
|
||||
MaxValue = newValue + delta;
|
||||
}
|
||||
else if (newValue < MinValue)
|
||||
{
|
||||
var delta = MaxValue - newValue;
|
||||
MinValue = newValue - delta;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int MinValue
|
||||
{
|
||||
get => _minValue;
|
||||
set => this.RaiseAndSetIfChanged(ref _minValue, value);
|
||||
}
|
||||
|
||||
public int MaxValue
|
||||
{
|
||||
get => _maxValue;
|
||||
set => this.RaiseAndSetIfChanged(ref _maxValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user