mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-22 21:06:30 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
34
ShareeSharedGuiLib/ShareeSharedGuiLib.projitems
Normal file
34
ShareeSharedGuiLib/ShareeSharedGuiLib.projitems
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>96fb99d1-0854-424f-b7ac-e52c3471cf9a</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>ShareeSharedGuiLib</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)View\BarLevelView.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Bar.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\BarLevelInputViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\BarLevelViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\BarLevelInputView.xaml.cs">
|
||||
<DependentUpon>BarLevelInputView.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\BarLevelView.xaml.cs">
|
||||
<DependentUpon>BarLevelView.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)View\BarLevelInputView.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
13
ShareeSharedGuiLib/ShareeSharedGuiLib.shproj
Normal file
13
ShareeSharedGuiLib/ShareeSharedGuiLib.shproj
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>96fb99d1-0854-424f-b7ac-e52c3471cf9a</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<PropertyGroup />
|
||||
<Import Project="ShareeSharedGuiLib.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
21
ShareeSharedGuiLib/View/BarLevelInputView.xaml
Normal file
21
ShareeSharedGuiLib/View/BarLevelInputView.xaml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:sharedGui="clr-namespace:ShareeSharedGuiLib.View"
|
||||
xmlns:resources="clr-namespace:TINK.MultilingualResources;assembly=TINKLib"
|
||||
x:Class="ShareeSharedGuiLib.View.BarLevelInputView">
|
||||
<ContentView.Content>
|
||||
<StackLayout>
|
||||
<Label
|
||||
Text="{x:Static resources:AppResources.MarkingDriveBatteryTitel}"/>
|
||||
<sharedGui:BarLevelView
|
||||
x:Name="BarLevelElement"
|
||||
Current="{Binding CurrentText, Mode=TwoWay}"
|
||||
Maximum="{Binding MaximumText}"/>
|
||||
<Stepper
|
||||
x:Name="BarLevelStepper"
|
||||
Value ="{Binding CurrentText, Mode=TwoWay}"
|
||||
Maximum="{Binding MaximumText}"/>
|
||||
</StackLayout>
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
110
ShareeSharedGuiLib/View/BarLevelInputView.xaml.cs
Normal file
110
ShareeSharedGuiLib/View/BarLevelInputView.xaml.cs
Normal file
|
@ -0,0 +1,110 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShareeSharedGuiLib.ViewModel;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace ShareeSharedGuiLib.View
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class BarLevelInputView : ContentView
|
||||
{
|
||||
private BarLevelInputViewModel _LocalViewModel;
|
||||
|
||||
public BarLevelInputView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_LocalViewModel = new BarLevelInputViewModel();
|
||||
|
||||
_LocalViewModel.PropertyChanged += (sender, args) =>
|
||||
{
|
||||
// Update Current property from view model on user input.
|
||||
if (args.PropertyName != nameof(BarLevelInputViewModel.Current))
|
||||
return;
|
||||
|
||||
var viewModel = sender as BarLevelInputViewModel;
|
||||
Current = viewModel?.Current != null
|
||||
? viewModel?.Current.Value.ToString()
|
||||
: String.Empty;
|
||||
};
|
||||
|
||||
// Do not bind entire control to local view model. Doing this would break binding of BatteryView control.
|
||||
this.BarLevelElement.BindingContext = _LocalViewModel;
|
||||
this.BarLevelStepper.BindingContext = _LocalViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create bindable property to to allow "Maximum"- proptery to act as a valid target for data binding.
|
||||
/// </summary>
|
||||
public static readonly BindableProperty MaximumProperty = BindableProperty.Create(
|
||||
"Maximum",
|
||||
typeof(string),
|
||||
typeof(BarLevelInputView),
|
||||
"7",
|
||||
propertyChanged: OnMaximumChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Holds the count of bars wich represent charing level full.
|
||||
/// </summary>
|
||||
public string Maximum
|
||||
{
|
||||
get => (string)GetValue(MaximumProperty);
|
||||
set => SetValue(MaximumProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies when value changes. Is required to make binding work.
|
||||
/// </summary>
|
||||
static void OnMaximumChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
var batteryView = bindable as BarLevelInputView;
|
||||
batteryView?.SetMaximum(int.TryParse(newValue.ToString(), out int maximum) ? (int?)maximum : null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMaximum(int? maximum) => _LocalViewModel.Maximum = maximum;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create bindable property to to allow "Current"- proptery to act as a valid target for data binding.
|
||||
/// </summary>
|
||||
public static readonly BindableProperty CurrentProperty = BindableProperty.Create(
|
||||
"Current",
|
||||
typeof(string),
|
||||
typeof(BarLevelInputView),
|
||||
"7",
|
||||
BindingMode.TwoWay,
|
||||
propertyChanged: OnCurrentChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Holds the count of bars wich represent the current charing level.
|
||||
/// </summary>
|
||||
public string Current
|
||||
{
|
||||
get => (string)GetValue(CurrentProperty);
|
||||
set => SetValue(CurrentProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies when value changes. Is required to make binding work.
|
||||
/// </summary>
|
||||
static void OnCurrentChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
var batteryView = bindable as BarLevelInputView;
|
||||
int current;
|
||||
batteryView?.SetCurrent(int.TryParse(newValue.ToString(), out current) ? (int?)current : null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrent(int? current) => _LocalViewModel.Current = current;
|
||||
|
||||
}
|
||||
}
|
20
ShareeSharedGuiLib/View/BarLevelView.xaml
Normal file
20
ShareeSharedGuiLib/View/BarLevelView.xaml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="ShareeSharedGuiLib.View.BarLevelView">
|
||||
<ContentView.Content>
|
||||
<StackLayout>
|
||||
<!-- Nice battery images symbolizing filling level for batteries with 5 bars -->
|
||||
<Image
|
||||
x:Name="BarLevelImage"
|
||||
WidthRequest="50"
|
||||
IsVisible="{Binding IsBatteryChargeLevelImageVisible}"
|
||||
Source="{Binding BatteryChargeLevelImageSourceString}"/>
|
||||
<!-- Text describing filling level batteries with 1...4 and 6..N bars -->
|
||||
<Label
|
||||
x:Name="BarLevelLabel"
|
||||
Text="{Binding BatteryChargeLevelBarsText}"
|
||||
IsVisible="{Binding IsBatteryChargeLevelLabelVisible}"/>
|
||||
</StackLayout>
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
94
ShareeSharedGuiLib/View/BarLevelView.xaml.cs
Normal file
94
ShareeSharedGuiLib/View/BarLevelView.xaml.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShareeSharedGuiLib.ViewModel;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace ShareeSharedGuiLib.View
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class BarLevelView : ContentView
|
||||
{
|
||||
private BarLevelViewModel _LocalViewModel = new BarLevelViewModel();
|
||||
|
||||
public BarLevelView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Do not bind entire control to local view model. Doing this would break binding of BatteryView control.
|
||||
this.BarLevelLabel.BindingContext = _LocalViewModel;
|
||||
this.BarLevelImage.BindingContext = _LocalViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create bindable property to to allow "Maximum"- proptery to act as a valid target for data binding.
|
||||
/// </summary>
|
||||
public static readonly BindableProperty MaximumProperty = BindableProperty.Create(
|
||||
"Maximum",
|
||||
typeof(string),
|
||||
typeof(BarLevelView),
|
||||
"", // Default value must match default value of view model object. Otherwise there might be an update issue.
|
||||
propertyChanged: OnMaximumChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Holds the count of bars wich represent charing level full.
|
||||
/// </summary>
|
||||
public string Maximum
|
||||
{
|
||||
get => (string)GetValue(MaximumProperty);
|
||||
set => SetValue(MaximumProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies when value changes. Is required to make binding work.
|
||||
/// </summary>
|
||||
static void OnMaximumChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
var batteryView = bindable as BarLevelView;
|
||||
batteryView?.SetMaximum(int.TryParse(newValue.ToString(), out int maximum) ? (int?)maximum : null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMaximum(int? maximum) => _LocalViewModel.Maximum = maximum;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create bindable property to to allow "Current"- proptery to act as a valid target for data binding.
|
||||
/// </summary>
|
||||
public static readonly BindableProperty CurrentProperty = BindableProperty.Create(
|
||||
"Current",
|
||||
typeof(string),
|
||||
typeof(BarLevelView),
|
||||
"", // Default value must match default value of view model object. Otherwise there might be an update issue.
|
||||
propertyChanged: OnCurrentChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Holds the count of bars wich represent the current charing level.
|
||||
/// </summary>
|
||||
public string Current
|
||||
{
|
||||
get => (string)GetValue(CurrentProperty);
|
||||
set => SetValue(CurrentProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies when value changes. Is required to make binding work.
|
||||
/// </summary>
|
||||
static void OnCurrentChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
var batteryView = bindable as BarLevelView;
|
||||
int current;
|
||||
batteryView?.SetCurrent(int.TryParse(newValue.ToString(), out current) ? (int?)current : null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrent(int? current) => _LocalViewModel.Current = current;
|
||||
}
|
||||
}
|
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