mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 12:36:28 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
37
ShareeSharedGuiLib/ViewModel/Bar.cs
Normal file
37
ShareeSharedGuiLib/ViewModel/Bar.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareeSharedGuiLib.ViewModel
|
||||
{
|
||||
public enum ChargingState
|
||||
{
|
||||
Loaded,
|
||||
Empty
|
||||
}
|
||||
|
||||
public class Bar
|
||||
{
|
||||
public Bar(ChargingState? state = null)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether bar is charged or not. Null if state is unknown.
|
||||
/// </summary>
|
||||
public ChargingState? State { get; private set; } = null;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (State == null)
|
||||
return string.Empty;
|
||||
|
||||
return State == ChargingState.Loaded ? " + " : " - ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
67
ShareeSharedGuiLib/ViewModel/BarLevelInputViewModel.cs
Normal file
67
ShareeSharedGuiLib/ViewModel/BarLevelInputViewModel.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
89
ShareeSharedGuiLib/ViewModel/BarLevelViewModel.cs
Normal file
89
ShareeSharedGuiLib/ViewModel/BarLevelViewModel.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
using System.ComponentModel;
|
||||
using TINK.MultilingualResources;
|
||||
|
||||
namespace ShareeSharedGuiLib.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Bar based filling level indicator view.
|
||||
/// </summary>
|
||||
public class BarLevelViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public int? _Maximum = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the maximum count of bars.
|
||||
/// </summary>
|
||||
public int? Maximum
|
||||
{
|
||||
get => _Maximum;
|
||||
set
|
||||
{
|
||||
if (_Maximum == value)
|
||||
{
|
||||
// Nothing to do because nothing changed.
|
||||
return;
|
||||
}
|
||||
|
||||
_Maximum = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsBatteryChargeLevelLabelVisible)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BatteryChargeLevelBarsText)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BatteryChargeLevelImageSourceString)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsBatteryChargeLevelImageVisible)));
|
||||
}
|
||||
}
|
||||
|
||||
public int? _Current = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current count of bars.
|
||||
/// </summary>
|
||||
public int? Current
|
||||
{
|
||||
get => _Current;
|
||||
set
|
||||
{
|
||||
if (_Current == value)
|
||||
{
|
||||
// Nothing to do because nothing changed.
|
||||
return;
|
||||
}
|
||||
|
||||
_Current = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsBatteryChargeLevelLabelVisible)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BatteryChargeLevelBarsText)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BatteryChargeLevelImageSourceString)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsBatteryChargeLevelImageVisible)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the battery filling level or pedelecs.
|
||||
/// </summary>
|
||||
public string BatteryChargeLevelBarsText => Maximum != null
|
||||
? string.Format(
|
||||
AppResources.MarkingDriveBatteryChargingLevel,
|
||||
Current != null ? Current.ToString() : "-",
|
||||
Maximum != null ? Maximum.ToString() : "-")
|
||||
: AppResources.MarkingDriveBatteryChargingLevelNotAvailable;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether battery label is visible or not.
|
||||
/// </summary>
|
||||
public bool IsBatteryChargeLevelLabelVisible => Maximum.HasValue && Maximum.Value != 5;
|
||||
|
||||
/// <summary>
|
||||
/// Gets name of battery image ressource.
|
||||
/// </summary>
|
||||
public string BatteryChargeLevelImageSourceString => Current.HasValue && Maximum.HasValue && Maximum.Value == 5
|
||||
? $"battery_{Current.Value}_{Maximum.Value}.png"
|
||||
: "battery_undefined.png";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether battery image is visible or not.
|
||||
/// </summary>
|
||||
public bool IsBatteryChargeLevelImageVisible => Maximum.HasValue && Maximum.Value == 5;
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue