mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 22:07:28 +02:00
Version 3.0.371
This commit is contained in:
parent
bdb2dec1c1
commit
6d22dbf40b
145 changed files with 2289 additions and 764 deletions
|
@ -2,32 +2,35 @@ using Serilog;
|
|||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the state of a chargeable battery.
|
||||
/// </summary>
|
||||
public class Battery : IBattery
|
||||
{
|
||||
private Battery() { }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// Gets the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
public double CurrentChargePercent { get; private set; } = double.NaN;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in bars, null if unknown.
|
||||
/// Gets the current charging level of the battery in bars, null if unknown.
|
||||
/// </summary>
|
||||
public int? CurrentChargeBars { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the maximum charging level of the battery in bars, null if unknown.
|
||||
/// Gets the maximum charging level of the battery in bars, null if unknown.
|
||||
/// </summary>
|
||||
public int? MaxChargeBars { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether backend is aware of battery charging level.
|
||||
/// Gets whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
public bool? IsBackendAccessible { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Holds whether to display battery level or not.
|
||||
/// Gets whether to display battery level or not.
|
||||
/// </summary>
|
||||
public bool? IsHidden { get; private set; } = null;
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
using System.ComponentModel;
|
||||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the state of a chargeable battery.
|
||||
/// </summary>
|
||||
public class BatteryMutable : IBatteryMutable, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
IBattery _battery;
|
||||
|
||||
public BatteryMutable(IBattery battery)
|
||||
{
|
||||
_battery = battery;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
public double CurrentChargePercent => _battery.CurrentChargePercent;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current charging level of the battery in bars, null if unknown.
|
||||
/// </summary>
|
||||
public int? CurrentChargeBars
|
||||
{
|
||||
get => _battery.CurrentChargeBars;
|
||||
set
|
||||
{
|
||||
double GetCurrentChargePercent()
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
// Filling level is unknown.
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
if (_battery.MaxChargeBars == null || _battery.MaxChargeBars == 0)
|
||||
{
|
||||
// Percentage filling level can not be calculated.
|
||||
return _battery.CurrentChargePercent;
|
||||
}
|
||||
|
||||
return (int)(100 * value / _battery.MaxChargeBars);
|
||||
}
|
||||
|
||||
if (_battery.CurrentChargeBars == value)
|
||||
{
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
_battery = new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = _battery.MaxChargeBars,
|
||||
IsBackendAccessible = _battery.IsBackendAccessible,
|
||||
IsHidden = _battery.IsHidden,
|
||||
CurrentChargeBars = value,
|
||||
CurrentChargePercent = GetCurrentChargePercent(),
|
||||
}.Build();
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentChargeBars)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentChargePercent)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum charging level of the battery in bars, null if unknown.
|
||||
/// </summary>
|
||||
public int? MaxChargeBars => _battery.MaxChargeBars;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
public bool? IsBackendAccessible => _battery.IsBackendAccessible;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to display battery level or not.
|
||||
/// </summary>
|
||||
public bool? IsHidden => _battery.IsHidden;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
public interface IBattery
|
||||
public interface IBattery
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using System.ComponentModel;
|
||||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the state of a chargeable battery.
|
||||
/// </summary>
|
||||
public interface IBatteryMutable : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current charging level of the battery in percent, double.NaN if unknown.
|
||||
/// </summary>
|
||||
double CurrentChargePercent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current charging level of the battery in bars. Must not be larger than MaxChargeBars, null if unknown.
|
||||
/// </summary>
|
||||
int? CurrentChargeBars { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum charging level of the battery in bars, null if unknown.
|
||||
/// </summary>
|
||||
int? MaxChargeBars { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether backend is aware of battery charging level.
|
||||
/// </summary>
|
||||
bool? IsBackendAccessible { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to display battery level or not.
|
||||
/// </summary>
|
||||
bool? IsHidden { get; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue