mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-22 23:26:31 +01:00
67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Text;
|
|
using System.Windows.Input;
|
|
using Xamarin.Forms;
|
|
|
|
namespace ShareeSharedGuiLib.ViewModel
|
|
{
|
|
/// <summary>
|
|
/// Bar based filling level view which shows filling level and allows to edit this level.
|
|
/// </summary>
|
|
public class BarLevelInputViewModel : INotifyPropertyChanged
|
|
{
|
|
public new event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public int? _Maximum = null;
|
|
|
|
public int? Maximum
|
|
{
|
|
get => _Maximum;
|
|
set
|
|
{
|
|
if (_Maximum == value)
|
|
{
|
|
// Nothing to do because nothing changed.
|
|
return;
|
|
}
|
|
|
|
_Maximum = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MaximumText)));
|
|
}
|
|
}
|
|
|
|
public string MaximumText => Maximum != null
|
|
? Maximum.Value.ToString()
|
|
: string.Empty;
|
|
|
|
public int? _Current = null;
|
|
|
|
public int? Current
|
|
{
|
|
get => _Current;
|
|
set
|
|
{
|
|
if (_Current == value)
|
|
{
|
|
// Nothing to do because nothing changed.
|
|
return;
|
|
}
|
|
|
|
_Current = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Current)));
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentText)));
|
|
}
|
|
}
|
|
|
|
public string CurrentText
|
|
{
|
|
get => Current != null
|
|
? Current.Value.ToString()
|
|
: string.Empty;
|
|
|
|
set => Current = int.TryParse(value, out int newCurrent) ? (int?)newCurrent : null;
|
|
}
|
|
}
|
|
}
|