mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -6,80 +6,80 @@ using TINK.Model.Services.CopriApi.ServerUris;
|
|||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
/// <summary> View model managing active uri and sets of uris. </summary>
|
||||
public class CopriServerUriListViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Object holding active uris.
|
||||
/// </summary>
|
||||
private CopriServerUriList m_oUris;
|
||||
/// <summary> View model managing active uri and sets of uris. </summary>
|
||||
public class CopriServerUriListViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Object holding active uris.
|
||||
/// </summary>
|
||||
private CopriServerUriList m_oUris;
|
||||
|
||||
/// <summary>
|
||||
/// Fired whenever a property changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
/// <summary>
|
||||
/// Fired whenever a property changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>Maps uris to user fiendly descriptions.</summary>
|
||||
private Dictionary<string, string> uriToServerText;
|
||||
/// <summary>Maps uris to user fiendly descriptions.</summary>
|
||||
private Dictionary<string, string> uriToServerText;
|
||||
|
||||
/// <summary>Maps user fiendly descriptions to uris.</summary>
|
||||
private Dictionary<string, string> serverTextToUri;
|
||||
/// <summary>Maps user fiendly descriptions to uris.</summary>
|
||||
private Dictionary<string, string> serverTextToUri;
|
||||
|
||||
public CopriServerUriListViewModel(CopriServerUriList p_oSource)
|
||||
{
|
||||
uriToServerText = new Dictionary<string, string> {
|
||||
{ CopriServerUriList.TINK_DEVEL, "TINK-Konrad-devellopment" },
|
||||
{ CopriServerUriList.TINK_LIVE, "TINK-Konrad-live" },
|
||||
{ CopriServerUriList.SHAREE_DEVEL, "Sharee-fr01-devellopment" },
|
||||
{ CopriServerUriList.SHAREE_LIVE, "Sharee-fr01-live" }
|
||||
};
|
||||
public CopriServerUriListViewModel(CopriServerUriList p_oSource)
|
||||
{
|
||||
uriToServerText = new Dictionary<string, string> {
|
||||
{ CopriServerUriList.TINK_DEVEL, "TINK-Konrad-devellopment" },
|
||||
{ CopriServerUriList.TINK_LIVE, "TINK-Konrad-live" },
|
||||
{ CopriServerUriList.SHAREE_DEVEL, "Sharee-fr01-devellopment" },
|
||||
{ CopriServerUriList.SHAREE_LIVE, "Sharee-fr01-live" }
|
||||
};
|
||||
|
||||
serverTextToUri = uriToServerText.ToDictionary(x => x.Value, x => x.Key);
|
||||
serverTextToUri = uriToServerText.ToDictionary(x => x.Value, x => x.Key);
|
||||
|
||||
m_oUris = new CopriServerUriList(p_oSource);
|
||||
NextActiveUri = m_oUris.ActiveUri;
|
||||
m_oUris = new CopriServerUriList(p_oSource);
|
||||
NextActiveUri = m_oUris.ActiveUri;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Gets the known uris text, i.e. binds to picker ItemsSource. </summary>
|
||||
public IList<string> ServerTextList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oUris.Uris.Select(x => (uriToServerText.ContainsKey(x.AbsoluteUri) ? uriToServerText[x.AbsoluteUri] : x.AbsoluteUri)).OrderBy(x => x).ToList();
|
||||
}
|
||||
}
|
||||
/// <summary> Gets the known uris text, i.e. binds to picker ItemsSource. </summary>
|
||||
public IList<string> ServerTextList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oUris.Uris.Select(x => (uriToServerText.ContainsKey(x.AbsoluteUri) ? uriToServerText[x.AbsoluteUri] : x.AbsoluteUri)).OrderBy(x => x).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Holds the uri which will be applied after restart of app. </summary>
|
||||
public Uri NextActiveUri { get; private set; }
|
||||
/// <summary> Holds the uri which will be applied after restart of app. </summary>
|
||||
public Uri NextActiveUri { get; private set; }
|
||||
|
||||
/// <summary> Holds the active uri, i.e. binds to picker SelectedItem. </summary>
|
||||
public string NextActiveServerText
|
||||
{
|
||||
get
|
||||
{
|
||||
return uriToServerText.ContainsKey(NextActiveUri.AbsoluteUri) ? uriToServerText[NextActiveUri.AbsoluteUri] : NextActiveUri.AbsoluteUri;
|
||||
}
|
||||
/// <summary> Holds the active uri, i.e. binds to picker SelectedItem. </summary>
|
||||
public string NextActiveServerText
|
||||
{
|
||||
get
|
||||
{
|
||||
return uriToServerText.ContainsKey(NextActiveUri.AbsoluteUri) ? uriToServerText[NextActiveUri.AbsoluteUri] : NextActiveUri.AbsoluteUri;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
NextActiveUri = new Uri(serverTextToUri.ContainsKey(value) ? serverTextToUri[value] : value);
|
||||
set
|
||||
{
|
||||
NextActiveUri = new Uri(serverTextToUri.ContainsKey(value) ? serverTextToUri[value] : value);
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CorpiServerUriDescription)));
|
||||
}
|
||||
}
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CorpiServerUriDescription)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Holds the description of the picker, i.e. binds to label Text.</summary>
|
||||
public string CorpiServerUriDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oUris.ActiveUri.AbsoluteUri == NextActiveUri.AbsoluteUri
|
||||
? "Aktiver Copri- Server"
|
||||
: "Copri- Server.\r\nNeustart erforderlich für Wechsel!";
|
||||
}
|
||||
}
|
||||
/// <summary> Holds the description of the picker, i.e. binds to label Text.</summary>
|
||||
public string CorpiServerUriDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oUris.ActiveUri.AbsoluteUri == NextActiveUri.AbsoluteUri
|
||||
? "Aktiver Copri- Server"
|
||||
: "Copri- Server.\r\nNeustart erforderlich für Wechsel!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,61 +2,61 @@
|
|||
|
||||
namespace TINK.ViewModel.Settings
|
||||
{
|
||||
/// <summary>Holds filter item incluting full state (avaialble, activated, name, ...). </summary>
|
||||
public class FilterItemMutable
|
||||
{
|
||||
/// <summary> Switch value</summary>
|
||||
private bool m_bIsActivatedSwitch;
|
||||
/// <summary>Holds filter item incluting full state (avaialble, activated, name, ...). </summary>
|
||||
public class FilterItemMutable
|
||||
{
|
||||
/// <summary> Switch value</summary>
|
||||
private bool m_bIsActivatedSwitch;
|
||||
|
||||
/// <summary> Constructs a filter object. </summary>
|
||||
/// <param name="key">Key of the filter state.</param>
|
||||
/// <param name="filterState">State of filter, on or off.</param>
|
||||
/// <param name="isEnabled">If filter does not apply because user does not belong to group (TINK, Konrad, ...) filter is deactivated.</param>
|
||||
/// <param name="labelText">Text of the switch describing the filter.</param>
|
||||
public FilterItemMutable(
|
||||
string key,
|
||||
FilterState filterState,
|
||||
bool isEnabled,
|
||||
string labelText)
|
||||
{
|
||||
Text = labelText;
|
||||
IsEnabled = isEnabled;
|
||||
State = filterState;
|
||||
Key = key;
|
||||
m_bIsActivatedSwitch = isEnabled && filterState == FilterState.On;
|
||||
}
|
||||
/// <summary> Constructs a filter object. </summary>
|
||||
/// <param name="key">Key of the filter state.</param>
|
||||
/// <param name="filterState">State of filter, on or off.</param>
|
||||
/// <param name="isEnabled">If filter does not apply because user does not belong to group (TINK, Konrad, ...) filter is deactivated.</param>
|
||||
/// <param name="labelText">Text of the switch describing the filter.</param>
|
||||
public FilterItemMutable(
|
||||
string key,
|
||||
FilterState filterState,
|
||||
bool isEnabled,
|
||||
string labelText)
|
||||
{
|
||||
Text = labelText;
|
||||
IsEnabled = isEnabled;
|
||||
State = filterState;
|
||||
Key = key;
|
||||
m_bIsActivatedSwitch = isEnabled && filterState == FilterState.On;
|
||||
}
|
||||
|
||||
/// <summary> Text describing the filter. </summary>
|
||||
public string Text { get; }
|
||||
/// <summary> Text describing the filter. </summary>
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary> True if switch can be toggeled.</summary>
|
||||
public bool IsEnabled { get; }
|
||||
/// <summary> True if switch can be toggeled.</summary>
|
||||
public bool IsEnabled { get; }
|
||||
|
||||
/// <summary> True if switch is on.</summary>
|
||||
public bool IsActivated
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsActivatedSwitch;
|
||||
}
|
||||
/// <summary> True if switch is on.</summary>
|
||||
public bool IsActivated
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsActivatedSwitch;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_bIsActivatedSwitch = value;
|
||||
if (!IsEnabled)
|
||||
{
|
||||
// Nothing to do if filter does not apply to user account.
|
||||
return;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bIsActivatedSwitch = value;
|
||||
if (!IsEnabled)
|
||||
{
|
||||
// Nothing to do if filter does not apply to user account.
|
||||
return;
|
||||
}
|
||||
|
||||
State = m_bIsActivatedSwitch ? FilterState.On : FilterState.Off;
|
||||
}
|
||||
}
|
||||
State = m_bIsActivatedSwitch ? FilterState.On : FilterState.Off;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Key of the filter.</summary>
|
||||
public string Key { get; }
|
||||
/// <summary> Key of the filter.</summary>
|
||||
public string Key { get; }
|
||||
|
||||
/// <summary> State of the filter.</summary>
|
||||
public FilterState State { get; private set; }
|
||||
}
|
||||
/// <summary> State of the filter.</summary>
|
||||
public FilterState State { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,34 +3,34 @@ using System.ComponentModel;
|
|||
|
||||
namespace TINK.ViewModel.Settings
|
||||
{
|
||||
/// <summary> Manages locks services and related parameters. </summary>
|
||||
public class LocksServicesViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private TimeSpan ConnectTimeout { get; set; }
|
||||
/// <summary> Manages locks services and related parameters. </summary>
|
||||
public class LocksServicesViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private TimeSpan ConnectTimeout { get; set; }
|
||||
|
||||
public LocksServicesViewModel(
|
||||
TimeSpan connectTimeout,
|
||||
ServicesViewModel servicesViewModel)
|
||||
{
|
||||
ConnectTimeout = connectTimeout;
|
||||
Services = servicesViewModel;
|
||||
}
|
||||
public LocksServicesViewModel(
|
||||
TimeSpan connectTimeout,
|
||||
ServicesViewModel servicesViewModel)
|
||||
{
|
||||
ConnectTimeout = connectTimeout;
|
||||
Services = servicesViewModel;
|
||||
}
|
||||
|
||||
public ServicesViewModel Services { get; }
|
||||
public ServicesViewModel Services { get; }
|
||||
|
||||
public string ConnectTimeoutSecText { get => ConnectTimeout.TotalSeconds.ToString(); }
|
||||
public string ConnectTimeoutSecText { get => ConnectTimeout.TotalSeconds.ToString(); }
|
||||
|
||||
public double ConnectTimeoutSec
|
||||
{
|
||||
get => ConnectTimeout.TotalSeconds;
|
||||
public double ConnectTimeoutSec
|
||||
{
|
||||
get => ConnectTimeout.TotalSeconds;
|
||||
|
||||
set
|
||||
{
|
||||
ConnectTimeout = TimeSpan.FromSeconds(value);
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ConnectTimeoutSecText)));
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
ConnectTimeout = TimeSpan.FromSeconds(value);
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ConnectTimeoutSecText)));
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
|
@ -4,107 +4,107 @@ using TINK.Settings;
|
|||
|
||||
namespace TINK.ViewModel.Settings
|
||||
{
|
||||
/// <summary> Polling relagted parameters</summary>
|
||||
public class PollingViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>Holds the views polling parameters.</summary>
|
||||
private PollingParameters m_oPolling = PollingParameters.Default;
|
||||
/// <summary> Polling relagted parameters</summary>
|
||||
public class PollingViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>Holds the views polling parameters.</summary>
|
||||
private PollingParameters m_oPolling = PollingParameters.Default;
|
||||
|
||||
/// <summary> Current polling periode. Used to check whether values were modified or not.</summary>
|
||||
private readonly PollingParameters m_oPollingActive;
|
||||
/// <summary> Current polling periode. Used to check whether values were modified or not.</summary>
|
||||
private readonly PollingParameters m_oPollingActive;
|
||||
|
||||
/// <summary> Constructs polling object. </summary>
|
||||
/// <param name="p_oSource">Object to construct from</param>
|
||||
public PollingViewModel(PollingParameters p_oSource)
|
||||
{
|
||||
m_oPollingActive = p_oSource
|
||||
?? throw new ArgumentException("Can not instantiate polling parameters view model- object. Polling parameter object is null.");
|
||||
/// <summary> Constructs polling object. </summary>
|
||||
/// <param name="p_oSource">Object to construct from</param>
|
||||
public PollingViewModel(PollingParameters p_oSource)
|
||||
{
|
||||
m_oPollingActive = p_oSource
|
||||
?? throw new ArgumentException("Can not instantiate polling parameters view model- object. Polling parameter object is null.");
|
||||
|
||||
m_oPolling = p_oSource;
|
||||
}
|
||||
m_oPolling = p_oSource;
|
||||
}
|
||||
|
||||
/// <summary> Gets the immutable version of polling parameters.</summary>
|
||||
/// <returns>Polling parameters object.</returns>
|
||||
public PollingParameters ToImmutable() { return m_oPolling; }
|
||||
/// <summary> Gets the immutable version of polling parameters.</summary>
|
||||
/// <returns>Polling parameters object.</returns>
|
||||
public PollingParameters ToImmutable() { return m_oPolling; }
|
||||
|
||||
/// <summary> Holds value whether polling is activated or not.</summary>
|
||||
public bool IsActivated
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oPolling.IsActivated;
|
||||
}
|
||||
/// <summary> Holds value whether polling is activated or not.</summary>
|
||||
public bool IsActivated
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oPolling.IsActivated;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value == m_oPolling.IsActivated)
|
||||
{
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == m_oPolling.IsActivated)
|
||||
{
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
m_oPolling = new PollingParameters(m_oPolling.Periode, value);
|
||||
m_oPolling = new PollingParameters(m_oPolling.Periode, value);
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsActivated)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSeconds)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSecondsText)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PollingText)));
|
||||
}
|
||||
}
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsActivated)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSeconds)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSecondsText)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PollingText)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gests or sets the polling periode [sec]. </summary>
|
||||
public int PeriodeTotalSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)m_oPolling.Periode.TotalSeconds;
|
||||
}
|
||||
/// <summary> Gests or sets the polling periode [sec]. </summary>
|
||||
public int PeriodeTotalSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)m_oPolling.Periode.TotalSeconds;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value == (int)m_oPolling.Periode.TotalSeconds)
|
||||
{
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == (int)m_oPolling.Periode.TotalSeconds)
|
||||
{
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
m_oPolling = new PollingParameters(new TimeSpan(0, 0, value), IsActivated);
|
||||
m_oPolling = new PollingParameters(new TimeSpan(0, 0, value), IsActivated);
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSeconds)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSecondsText)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PollingText)));
|
||||
}
|
||||
}
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSeconds)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeTotalSecondsText)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PollingText)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets info about polling periode.</summary>
|
||||
public string PeriodeTotalSecondsText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsActivated)
|
||||
{
|
||||
return $"Polling Periode: {PeriodeTotalSeconds} [Sek.]";
|
||||
}
|
||||
/// <summary> Gets info about polling periode.</summary>
|
||||
public string PeriodeTotalSecondsText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsActivated)
|
||||
{
|
||||
return $"Polling Periode: {PeriodeTotalSeconds} [Sek.]";
|
||||
}
|
||||
|
||||
return $"Polling abgeschalten.";
|
||||
}
|
||||
}
|
||||
return $"Polling abgeschalten.";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the text of the polling related controls.</summary>
|
||||
public string PollingText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_oPolling == m_oPollingActive)
|
||||
{
|
||||
return "Polling";
|
||||
}
|
||||
/// <summary> Gets the text of the polling related controls.</summary>
|
||||
public string PollingText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_oPolling == m_oPollingActive)
|
||||
{
|
||||
return "Polling";
|
||||
}
|
||||
|
||||
return "Polling\r\nAnsicht verlassen um Änderungen anzuwenden.";
|
||||
}
|
||||
}
|
||||
return "Polling\r\nAnsicht verlassen um Änderungen anzuwenden.";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Notifies GUI about modified values.</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
/// <summary> Notifies GUI about modified values.</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,75 +6,75 @@ using Serilog;
|
|||
|
||||
namespace TINK.ViewModel.Settings
|
||||
{
|
||||
/// <summary> ViewModel for an active service plus a list of services which are not active.</summary>
|
||||
/// <remarks>
|
||||
/// Example for services are lock services, geolocation services, ...,
|
||||
/// </remarks>
|
||||
public class ServicesViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Active service. </summary>
|
||||
private string active;
|
||||
/// <summary> ViewModel for an active service plus a list of services which are not active.</summary>
|
||||
/// <remarks>
|
||||
/// Example for services are lock services, geolocation services, ...,
|
||||
/// </remarks>
|
||||
public class ServicesViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Active service. </summary>
|
||||
private string active;
|
||||
|
||||
/// <summary> Holds the dictionary which maps services to service display texts.</summary>
|
||||
private IDictionary<string, string> ServiceToText { get; }
|
||||
/// <summary> Holds the dictionary which maps services to service display texts.</summary>
|
||||
private IDictionary<string, string> ServiceToText { get; }
|
||||
|
||||
/// <summary> Holds the dictionary which maps service display texts to services.</summary>
|
||||
private IDictionary<string, string> TextToService { get; }
|
||||
/// <summary> Holds the dictionary which maps service display texts to services.</summary>
|
||||
private IDictionary<string, string> TextToService { get; }
|
||||
|
||||
/// <summary>Constructs view model ensuring consistency. </summary>
|
||||
/// <param name="services">List of available services.</param>
|
||||
/// <param name="serviceToText"> Dictionary holding display text for services as values.</param>
|
||||
/// <param name="active">Active service.</param>
|
||||
public ServicesViewModel(
|
||||
IEnumerable<string> services,
|
||||
IDictionary<string, string> serviceToText,
|
||||
string active)
|
||||
{
|
||||
if (!services.Contains(active))
|
||||
throw new ArgumentException($"Can not instantiate {typeof(ServicesViewModel).Name}- object. Active lock service {active} must be contained in [{String.Join(",", services)}].");
|
||||
/// <summary>Constructs view model ensuring consistency. </summary>
|
||||
/// <param name="services">List of available services.</param>
|
||||
/// <param name="serviceToText"> Dictionary holding display text for services as values.</param>
|
||||
/// <param name="active">Active service.</param>
|
||||
public ServicesViewModel(
|
||||
IEnumerable<string> services,
|
||||
IDictionary<string, string> serviceToText,
|
||||
string active)
|
||||
{
|
||||
if (!services.Contains(active))
|
||||
throw new ArgumentException($"Can not instantiate {typeof(ServicesViewModel).Name}- object. Active lock service {active} must be contained in [{String.Join(",", services)}].");
|
||||
|
||||
ServiceToText = services.Distinct().ToDictionary(
|
||||
x => x,
|
||||
x => serviceToText.ContainsKey(x) ? serviceToText[x] : x);
|
||||
ServiceToText = services.Distinct().ToDictionary(
|
||||
x => x,
|
||||
x => serviceToText.ContainsKey(x) ? serviceToText[x] : x);
|
||||
|
||||
TextToService = ServiceToText.ToDictionary(x => x.Value, x => x.Key);
|
||||
Active = active;
|
||||
}
|
||||
TextToService = ServiceToText.ToDictionary(x => x.Value, x => x.Key);
|
||||
Active = active;
|
||||
}
|
||||
|
||||
/// <summary> Fired whenever active service changes.</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
/// <summary> Fired whenever active service changes.</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary> Holds active service.</summary>
|
||||
public string Active
|
||||
{
|
||||
get => active;
|
||||
set
|
||||
{
|
||||
if (active == value)
|
||||
return;
|
||||
/// <summary> Holds active service.</summary>
|
||||
public string Active
|
||||
{
|
||||
get => active;
|
||||
set
|
||||
{
|
||||
if (active == value)
|
||||
return;
|
||||
|
||||
active = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Active)));
|
||||
}
|
||||
}
|
||||
active = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Active)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> List of display texts of services.</summary>
|
||||
public IList<string> ServicesTextList => ServiceToText.Select(x => x.Value).OrderBy(x => x).ToList();
|
||||
/// <summary> List of display texts of services.</summary>
|
||||
public IList<string> ServicesTextList => ServiceToText.Select(x => x.Value).OrderBy(x => x).ToList();
|
||||
|
||||
/// <summary> Active locks service.</summary>
|
||||
public string ActiveText
|
||||
{
|
||||
get => ServiceToText[Active];
|
||||
set
|
||||
{
|
||||
if (!TextToService.ContainsKey(value))
|
||||
{
|
||||
Log.ForContext<ServicesViewModel>().Error($"Can not set service {value} to services view model. List of services {{{string.Join(";", TextToService)}}} does not hold machting element.");
|
||||
throw new ArgumentException($"Can not set service {value} to services view model. List of services {{{string.Join(";", TextToService)}}} does not hold machting element.");
|
||||
}
|
||||
/// <summary> Active locks service.</summary>
|
||||
public string ActiveText
|
||||
{
|
||||
get => ServiceToText[Active];
|
||||
set
|
||||
{
|
||||
if (!TextToService.ContainsKey(value))
|
||||
{
|
||||
Log.ForContext<ServicesViewModel>().Error($"Can not set service {value} to services view model. List of services {{{string.Join(";", TextToService)}}} does not hold machting element.");
|
||||
throw new ArgumentException($"Can not set service {value} to services view model. List of services {{{string.Join(";", TextToService)}}} does not hold machting element.");
|
||||
}
|
||||
|
||||
Active = TextToService[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
Active = TextToService[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,59 +7,59 @@ using TINK.MultilingualResources;
|
|||
|
||||
namespace TINK.ViewModel.Settings
|
||||
{
|
||||
/// <summary> Holds the filters to display..</summary>
|
||||
/// <remarks> Former name: FilterCollectionMutable.</remarks>
|
||||
public class SettingsBikeFilterViewModel : ObservableCollection<FilterItemMutable>
|
||||
{
|
||||
/// <summary> Constructs a filter collection object.</summary>
|
||||
/// <param name="filterSettings">All available filters.</param>
|
||||
/// <param name="filterGroupUser">Filters which apply to logged in user.</param>
|
||||
public SettingsBikeFilterViewModel(
|
||||
IGroupFilterSettings filterSettings,
|
||||
IEnumerable<string> filterGroupUser)
|
||||
{
|
||||
foreach (var filter in filterSettings)
|
||||
{
|
||||
if (filter.Key == FilterHelper.CARGOBIKE)
|
||||
{
|
||||
Add(new FilterItemMutable(
|
||||
filter.Key,
|
||||
filter.Value,
|
||||
(filterGroupUser != null && filterGroupUser.Count() > 0) ? filterGroupUser.Contains(filter.Key) : true,
|
||||
AppResources.MarkingCargoBike));
|
||||
continue;
|
||||
}
|
||||
if (filter.Key == FilterHelper.CITYBIKE)
|
||||
{
|
||||
Add(new FilterItemMutable(
|
||||
filter.Key,
|
||||
filter.Value,
|
||||
(filterGroupUser != null && filterGroupUser.Count() > 0) ? filterGroupUser.Contains(filter.Key) : true,
|
||||
AppResources.MarkingCityBike));
|
||||
continue;
|
||||
}
|
||||
/// <summary> Holds the filters to display..</summary>
|
||||
/// <remarks> Former name: FilterCollectionMutable.</remarks>
|
||||
public class SettingsBikeFilterViewModel : ObservableCollection<FilterItemMutable>
|
||||
{
|
||||
/// <summary> Constructs a filter collection object.</summary>
|
||||
/// <param name="filterSettings">All available filters.</param>
|
||||
/// <param name="filterGroupUser">Filters which apply to logged in user.</param>
|
||||
public SettingsBikeFilterViewModel(
|
||||
IGroupFilterSettings filterSettings,
|
||||
IEnumerable<string> filterGroupUser)
|
||||
{
|
||||
foreach (var filter in filterSettings)
|
||||
{
|
||||
if (filter.Key == FilterHelper.CARGOBIKE)
|
||||
{
|
||||
Add(new FilterItemMutable(
|
||||
filter.Key,
|
||||
filter.Value,
|
||||
(filterGroupUser != null && filterGroupUser.Count() > 0) ? filterGroupUser.Contains(filter.Key) : true,
|
||||
AppResources.MarkingCargoBike));
|
||||
continue;
|
||||
}
|
||||
if (filter.Key == FilterHelper.CITYBIKE)
|
||||
{
|
||||
Add(new FilterItemMutable(
|
||||
filter.Key,
|
||||
filter.Value,
|
||||
(filterGroupUser != null && filterGroupUser.Count() > 0) ? filterGroupUser.Contains(filter.Key) : true,
|
||||
AppResources.MarkingCityBike));
|
||||
continue;
|
||||
}
|
||||
|
||||
Add(new FilterItemMutable(
|
||||
filter.Key,
|
||||
filter.Value,
|
||||
filterGroupUser != null ? filterGroupUser.Contains(filter.Key) : true,
|
||||
filter.Key));
|
||||
}
|
||||
}
|
||||
Add(new FilterItemMutable(
|
||||
filter.Key,
|
||||
filter.Value,
|
||||
filterGroupUser != null ? filterGroupUser.Contains(filter.Key) : true,
|
||||
filter.Key));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Get filter collection which might have been modified for serialization purposes.</summary>
|
||||
public Dictionary<string, FilterState> FilterCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
var dictionary = new Dictionary<string, FilterState>();
|
||||
foreach (var entry in this)
|
||||
{
|
||||
dictionary.Add(entry.Key, entry.State);
|
||||
}
|
||||
/// <summary> Get filter collection which might have been modified for serialization purposes.</summary>
|
||||
public Dictionary<string, FilterState> FilterCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
var dictionary = new Dictionary<string, FilterState>();
|
||||
foreach (var entry in this)
|
||||
{
|
||||
dictionary.Add(entry.Key, entry.State);
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,383 +20,383 @@ using Xamarin.Forms;
|
|||
|
||||
namespace TINK.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// View model for settings.
|
||||
/// </summary>
|
||||
public class SettingsPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService m_oViewService;
|
||||
/// <summary>
|
||||
/// View model for settings.
|
||||
/// </summary>
|
||||
public class SettingsPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService m_oViewService;
|
||||
|
||||
/// <summary>
|
||||
/// Fired if a property changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
/// <summary>
|
||||
/// Fired if a property changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary> Object to manage update of view model objects from Copri.</summary>
|
||||
private IPollingUpdateTaskManager m_oViewUpdateManager;
|
||||
/// <summary> Object to manage update of view model objects from Copri.</summary>
|
||||
private IPollingUpdateTaskManager m_oViewUpdateManager;
|
||||
|
||||
/// <summary> List of copri server uris.</summary>
|
||||
public CopriServerUriListViewModel CopriServerUriList { get; }
|
||||
/// <summary> List of copri server uris.</summary>
|
||||
public CopriServerUriListViewModel CopriServerUriList { get; }
|
||||
|
||||
/// <summary> Manages selection of locks services.</summary>
|
||||
public LocksServicesViewModel LocksServices { get; }
|
||||
/// <summary> Manages selection of locks services.</summary>
|
||||
public LocksServicesViewModel LocksServices { get; }
|
||||
|
||||
/// <summary> Manages selection of geolocation services.</summary>
|
||||
public ServicesViewModel GeolocationServices { get; }
|
||||
/// <summary> Manages selection of geolocation services.</summary>
|
||||
public ServicesViewModel GeolocationServices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Object to switch logging level.
|
||||
/// </summary>
|
||||
private LogEventLevel m_oMinimumLogEventLevel;
|
||||
/// <summary>
|
||||
/// Object to switch logging level.
|
||||
/// </summary>
|
||||
private LogEventLevel m_oMinimumLogEventLevel;
|
||||
|
||||
/// <summary> Gets a value indicating whether reporting level is verbose or not.</summary>
|
||||
public bool IsReportLevelVerbose { get; set; }
|
||||
/// <summary> Gets a value indicating whether reporting level is verbose or not.</summary>
|
||||
public bool IsReportLevelVerbose { get; set; }
|
||||
|
||||
/// <summary> List of copri server uris.</summary>
|
||||
public ServicesViewModel Themes { get; }
|
||||
/// <summary> List of copri server uris.</summary>
|
||||
public ServicesViewModel Themes { get; }
|
||||
|
||||
/// <summary> Reference on the tink app instance. </summary>
|
||||
private ITinkApp TinkApp { get; }
|
||||
/// <summary> Reference on the tink app instance. </summary>
|
||||
private ITinkApp TinkApp { get; }
|
||||
|
||||
IServicesContainer<IGeolocation> GeoloctionServicesContainer { get; }
|
||||
IServicesContainer<IGeolocation> GeoloctionServicesContainer { get; }
|
||||
|
||||
/// <summary> Constructs a settings page view model object.</summary>
|
||||
/// <param name="tinkApp"> Reference to tink app model.</param>
|
||||
/// <param name="geoloctionServicesContainer"></param>
|
||||
/// <param name="viewService">Interface to view</param>
|
||||
public SettingsPageViewModel(
|
||||
ITinkApp tinkApp,
|
||||
IServicesContainer<IGeolocation> geoloctionServicesContainer,
|
||||
IViewService viewService)
|
||||
{
|
||||
TinkApp = tinkApp
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No tink app object available.");
|
||||
/// <summary> Constructs a settings page view model object.</summary>
|
||||
/// <param name="tinkApp"> Reference to tink app model.</param>
|
||||
/// <param name="geoloctionServicesContainer"></param>
|
||||
/// <param name="viewService">Interface to view</param>
|
||||
public SettingsPageViewModel(
|
||||
ITinkApp tinkApp,
|
||||
IServicesContainer<IGeolocation> geoloctionServicesContainer,
|
||||
IViewService viewService)
|
||||
{
|
||||
TinkApp = tinkApp
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No tink app object available.");
|
||||
|
||||
GeoloctionServicesContainer = geoloctionServicesContainer
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(SettingsPageViewModel)}- object. Geolocation services container object must not be null.");
|
||||
GeoloctionServicesContainer = geoloctionServicesContainer
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(SettingsPageViewModel)}- object. Geolocation services container object must not be null.");
|
||||
|
||||
m_oViewService = viewService
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No user view service available.");
|
||||
m_oViewService = viewService
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No user view service available.");
|
||||
|
||||
m_oMinimumLogEventLevel = TinkApp.MinimumLogEventLevel;
|
||||
m_oMinimumLogEventLevel = TinkApp.MinimumLogEventLevel;
|
||||
|
||||
IsReportLevelVerbose = TinkApp.IsReportLevelVerbose;
|
||||
IsReportLevelVerbose = TinkApp.IsReportLevelVerbose;
|
||||
|
||||
CenterMapToCurrentLocation = TinkApp.CenterMapToCurrentLocation;
|
||||
CenterMapToCurrentLocation = TinkApp.CenterMapToCurrentLocation;
|
||||
|
||||
ExternalFolder = TinkApp.ExternalFolder;
|
||||
ExternalFolder = TinkApp.ExternalFolder;
|
||||
|
||||
IsLogToExternalFolderVisible = !string.IsNullOrEmpty(ExternalFolder);
|
||||
IsLogToExternalFolderVisible = !string.IsNullOrEmpty(ExternalFolder);
|
||||
|
||||
LogToExternalFolderDisplayValue = IsLogToExternalFolderVisible ? TinkApp.LogToExternalFolder : false;
|
||||
LogToExternalFolderDisplayValue = IsLogToExternalFolderVisible ? TinkApp.LogToExternalFolder : false;
|
||||
|
||||
IsSiteCachingOnDisplayValue = TinkApp.IsSiteCachingOn;
|
||||
IsSiteCachingOnDisplayValue = TinkApp.IsSiteCachingOn;
|
||||
|
||||
if (TinkApp.Uris == null
|
||||
|| TinkApp.Uris.Uris.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Can not instantiate settings page view model- object. No uri- list available.");
|
||||
}
|
||||
if (TinkApp.Uris == null
|
||||
|| TinkApp.Uris.Uris.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Can not instantiate settings page view model- object. No uri- list available.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(TinkApp.NextActiveUri.AbsoluteUri))
|
||||
{
|
||||
throw new ArgumentException("Can not instantiate settings page view model- object. Next active uri must not be null or empty.");
|
||||
}
|
||||
if (string.IsNullOrEmpty(TinkApp.NextActiveUri.AbsoluteUri))
|
||||
{
|
||||
throw new ArgumentException("Can not instantiate settings page view model- object. Next active uri must not be null or empty.");
|
||||
}
|
||||
|
||||
GroupFilter = new SettingsBikeFilterViewModel(
|
||||
TinkApp.FilterGroupSetting,
|
||||
TinkApp.ActiveUser.IsLoggedIn ? TinkApp.ActiveUser.Group : null);
|
||||
GroupFilter = new SettingsBikeFilterViewModel(
|
||||
TinkApp.FilterGroupSetting,
|
||||
TinkApp.ActiveUser.IsLoggedIn ? TinkApp.ActiveUser.Group : null);
|
||||
|
||||
m_oViewUpdateManager = new IdlePollingUpdateTaskManager();
|
||||
m_oViewUpdateManager = new IdlePollingUpdateTaskManager();
|
||||
|
||||
Polling = new PollingViewModel(TinkApp.Polling);
|
||||
Polling = new PollingViewModel(TinkApp.Polling);
|
||||
|
||||
ExpiresAfterTotalSeconds = Convert.ToInt32(TinkApp.ExpiresAfter.TotalSeconds);
|
||||
ExpiresAfterTotalSeconds = Convert.ToInt32(TinkApp.ExpiresAfter.TotalSeconds);
|
||||
|
||||
CopriServerUriList = new CopriServerUriListViewModel(TinkApp.Uris);
|
||||
CopriServerUriList = new CopriServerUriListViewModel(TinkApp.Uris);
|
||||
|
||||
Themes = new ServicesViewModel(
|
||||
TinkApp.Themes.Select(x => x.GetType().FullName),
|
||||
new Dictionary<string, string> {
|
||||
{ typeof(Themes.Konrad).FullName, "Mein konrad" /* display name in picker */},
|
||||
{ typeof(Themes.ShareeBike).FullName, "sharee.bike" /* display name in picker */},
|
||||
{ typeof(Themes.LastenradBayern).FullName, "LastenradBayern" /* display name in picker */}
|
||||
},
|
||||
TinkApp.Themes.Active.GetType().FullName);
|
||||
Themes = new ServicesViewModel(
|
||||
TinkApp.Themes.Select(x => x.GetType().FullName),
|
||||
new Dictionary<string, string> {
|
||||
{ typeof(Themes.Konrad).FullName, "Mein konrad" /* display name in picker */},
|
||||
{ typeof(Themes.ShareeBike).FullName, "sharee.bike" /* display name in picker */},
|
||||
{ typeof(Themes.LastenradBayern).FullName, "LastenradBayern" /* display name in picker */}
|
||||
},
|
||||
TinkApp.Themes.Active.GetType().FullName);
|
||||
|
||||
Themes.PropertyChanged += OnThemesChanged;
|
||||
Themes.PropertyChanged += OnThemesChanged;
|
||||
|
||||
|
||||
LocksServices = new LocksServicesViewModel(
|
||||
TinkApp.LocksServices.Active.TimeOut.MultiConnect,
|
||||
new ServicesViewModel(
|
||||
TinkApp.LocksServices,
|
||||
new Dictionary<string, string> {
|
||||
{ typeof(LocksServiceInReach).FullName, "Simulation - AllLocksInReach" },
|
||||
{ typeof(LocksServiceOutOfReach).FullName, "Simulation - AllLocksOutOfReach" },
|
||||
{ typeof(Services.BluetoothLock.BLE.LockItByScanServiceEventBased).FullName, "Live - Scan" },
|
||||
{ typeof(Services.BluetoothLock.BLE.LockItByScanServicePolling).FullName, "Live - Scan (Polling)" },
|
||||
{ typeof(Services.BluetoothLock.BLE.LockItByGuidService).FullName, "Live - Guid" },
|
||||
LocksServices = new LocksServicesViewModel(
|
||||
TinkApp.LocksServices.Active.TimeOut.MultiConnect,
|
||||
new ServicesViewModel(
|
||||
TinkApp.LocksServices,
|
||||
new Dictionary<string, string> {
|
||||
{ typeof(LocksServiceInReach).FullName, "Simulation - AllLocksInReach" },
|
||||
{ typeof(LocksServiceOutOfReach).FullName, "Simulation - AllLocksOutOfReach" },
|
||||
{ typeof(Services.BluetoothLock.BLE.LockItByScanServiceEventBased).FullName, "Live - Scan" },
|
||||
{ typeof(Services.BluetoothLock.BLE.LockItByScanServicePolling).FullName, "Live - Scan (Polling)" },
|
||||
{ typeof(Services.BluetoothLock.BLE.LockItByGuidService).FullName, "Live - Guid" },
|
||||
/* { typeof(Services.BluetoothLock.Arendi.LockItByGuidService).FullName, "Live - Guid (Arendi)" },
|
||||
{ typeof(Services.BluetoothLock.Arendi.LockItByScanService).FullName, "Live - Scan (Arendi)" },
|
||||
{ typeof(Services.BluetoothLock.Bluetoothle.LockItByGuidService).FullName, "Live - Guid (Ritchie)" }, */
|
||||
},
|
||||
TinkApp.LocksServices.Active.GetType().FullName));
|
||||
TinkApp.LocksServices.Active.GetType().FullName));
|
||||
|
||||
GeolocationServices = new ServicesViewModel(
|
||||
GeoloctionServicesContainer.Select(x => x.GetType().FullName),
|
||||
new Dictionary<string, string> {
|
||||
{ typeof(LastKnownGeolocationService).FullName, "LastKnowGeolocation" },
|
||||
{ typeof(GeolocationAccuracyMediumService).FullName, "Medium Accuracy" },
|
||||
{ typeof(GeolocationAccuracyHighService).FullName, "High Accuracy" },
|
||||
{ typeof(GeolocationAccuracyBestService).FullName, "Best Accuracy" },
|
||||
{ typeof(SimulatedGeolocationService).FullName, "Simulation-AlwaysSamePosition" } },
|
||||
GeoloctionServicesContainer.Active.GetType().FullName);
|
||||
}
|
||||
GeolocationServices = new ServicesViewModel(
|
||||
GeoloctionServicesContainer.Select(x => x.GetType().FullName),
|
||||
new Dictionary<string, string> {
|
||||
{ typeof(LastKnownGeolocationService).FullName, "LastKnowGeolocation" },
|
||||
{ typeof(GeolocationAccuracyMediumService).FullName, "Medium Accuracy" },
|
||||
{ typeof(GeolocationAccuracyHighService).FullName, "High Accuracy" },
|
||||
{ typeof(GeolocationAccuracyBestService).FullName, "Best Accuracy" },
|
||||
{ typeof(SimulatedGeolocationService).FullName, "Simulation-AlwaysSamePosition" } },
|
||||
GeoloctionServicesContainer.Active.GetType().FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User switches scheme.
|
||||
/// </summary>
|
||||
private void OnThemesChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
// Set active theme (leads to switch of title)
|
||||
TinkApp.Themes.SetActive(Themes.Active);
|
||||
/// <summary>
|
||||
/// User switches scheme.
|
||||
/// </summary>
|
||||
private void OnThemesChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
// Set active theme (leads to switch of title)
|
||||
TinkApp.Themes.SetActive(Themes.Active);
|
||||
|
||||
// Switch theme.
|
||||
ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries;
|
||||
if (mergedDictionaries == null)
|
||||
{
|
||||
Log.ForContext<SettingsPageViewModel>().Error("No merged dictionary available.");
|
||||
return;
|
||||
}
|
||||
// Switch theme.
|
||||
ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries;
|
||||
if (mergedDictionaries == null)
|
||||
{
|
||||
Log.ForContext<SettingsPageViewModel>().Error("No merged dictionary available.");
|
||||
return;
|
||||
}
|
||||
|
||||
mergedDictionaries.Clear();
|
||||
mergedDictionaries.Clear();
|
||||
|
||||
if (Themes.Active == typeof(Themes.Konrad).FullName)
|
||||
{
|
||||
mergedDictionaries.Add(new Themes.Konrad());
|
||||
}
|
||||
else if (Themes.Active == typeof(Themes.ShareeBike).FullName)
|
||||
{
|
||||
mergedDictionaries.Add(new Themes.ShareeBike());
|
||||
}
|
||||
else if (Themes.Active == typeof(Themes.LastenradBayern).FullName)
|
||||
{
|
||||
mergedDictionaries.Add(new Themes.LastenradBayern());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<SettingsPageViewModel>().Debug($"No theme {Themes.Active} found.");
|
||||
}
|
||||
}
|
||||
if (Themes.Active == typeof(Themes.Konrad).FullName)
|
||||
{
|
||||
mergedDictionaries.Add(new Themes.Konrad());
|
||||
}
|
||||
else if (Themes.Active == typeof(Themes.ShareeBike).FullName)
|
||||
{
|
||||
mergedDictionaries.Add(new Themes.ShareeBike());
|
||||
}
|
||||
else if (Themes.Active == typeof(Themes.LastenradBayern).FullName)
|
||||
{
|
||||
mergedDictionaries.Add(new Themes.LastenradBayern());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<SettingsPageViewModel>().Debug($"No theme {Themes.Active} found.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Holds information whether app is connected to web or not. </summary>
|
||||
private bool? isConnected = null;
|
||||
/// <summary> Holds information whether app is connected to web or not. </summary>
|
||||
private bool? isConnected = null;
|
||||
|
||||
/// <summary>Exposes the is connected state. </summary>
|
||||
private bool IsConnected
|
||||
{
|
||||
get => isConnected ?? false;
|
||||
set
|
||||
{
|
||||
isConnected = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Exposes the is connected state. </summary>
|
||||
private bool IsConnected
|
||||
{
|
||||
get => isConnected ?? false;
|
||||
set
|
||||
{
|
||||
isConnected = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Holds a value indicating whether group filters GUI are visible or not</summary>
|
||||
public bool IsGroupFilterVisible => GroupFilter.Count > 0;
|
||||
/// <summary> Holds a value indicating whether group filters GUI are visible or not</summary>
|
||||
public bool IsGroupFilterVisible => GroupFilter.Count > 0;
|
||||
|
||||
/// <summary> Holds the bike types to fade out or show</summary>
|
||||
public SettingsBikeFilterViewModel GroupFilter { get; }
|
||||
/// <summary> Holds the bike types to fade out or show</summary>
|
||||
public SettingsBikeFilterViewModel GroupFilter { get; }
|
||||
|
||||
/// <summary> Gets the value to path were copri mock files are located (for debugging purposes).</summary>
|
||||
public string ExternalFolder { get; }
|
||||
/// <summary> Gets the value to path were copri mock files are located (for debugging purposes).</summary>
|
||||
public string ExternalFolder { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value to path were copri mock files are located (for debugging purposes).
|
||||
/// </summary>
|
||||
public string InternalPath => TinkApp.SettingsFileFolder;
|
||||
/// <summary>
|
||||
/// Gets the value to path were copri mock files are located (for debugging purposes).
|
||||
/// </summary>
|
||||
public string InternalPath => TinkApp.SettingsFileFolder;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of device identifier (for debugging purposes).
|
||||
/// </summary>
|
||||
public string DeviceIdentifier
|
||||
{
|
||||
get { return TinkApp.SmartDevice.Identifier; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the value of device identifier (for debugging purposes).
|
||||
/// </summary>
|
||||
public string DeviceIdentifier
|
||||
{
|
||||
get { return TinkApp.SmartDevice.Identifier; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when page is shutdown.
|
||||
/// Currently invoked by code behind, would be nice if called by XAML in future versions.
|
||||
/// </summary>
|
||||
public async Task OnDisappearing()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.ForContext<SettingsPageViewModel>().Information($"Entering {nameof(OnDisappearing)}...");
|
||||
/// <summary>
|
||||
/// Invoked when page is shutdown.
|
||||
/// Currently invoked by code behind, would be nice if called by XAML in future versions.
|
||||
/// </summary>
|
||||
public async Task OnDisappearing()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.ForContext<SettingsPageViewModel>().Information($"Entering {nameof(OnDisappearing)}...");
|
||||
|
||||
// Update model values.
|
||||
TinkApp.NextActiveUri = CopriServerUriList.NextActiveUri;
|
||||
// Update model values.
|
||||
TinkApp.NextActiveUri = CopriServerUriList.NextActiveUri;
|
||||
|
||||
TinkApp.Polling = new PollingParameters(
|
||||
new TimeSpan(0, 0, Polling.PeriodeTotalSeconds),
|
||||
Polling.IsActivated);
|
||||
TinkApp.Polling = new PollingParameters(
|
||||
new TimeSpan(0, 0, Polling.PeriodeTotalSeconds),
|
||||
Polling.IsActivated);
|
||||
|
||||
TinkApp.ExpiresAfter = TimeSpan.FromSeconds(ExpiresAfterTotalSeconds);
|
||||
TinkApp.ExpiresAfter = TimeSpan.FromSeconds(ExpiresAfterTotalSeconds);
|
||||
|
||||
var filterGroup = GroupFilter.ToDictionary(x => x.Key, x => x.State);
|
||||
TinkApp.FilterGroupSetting = new GroupFilterSettings(filterGroup.Count > 0 ? filterGroup : null);
|
||||
var filterGroup = GroupFilter.ToDictionary(x => x.Key, x => x.State);
|
||||
TinkApp.FilterGroupSetting = new GroupFilterSettings(filterGroup.Count > 0 ? filterGroup : null);
|
||||
|
||||
// Update map page filter.
|
||||
// Reasons for which map page filter has to be updated:
|
||||
// - user activated/ deactivated a group (TINKCorpi/ TINKSms/ Konrad)
|
||||
// - user logged off
|
||||
TinkApp.GroupFilterMapPage =
|
||||
GroupFilterMapPageHelper.CreateUpdated(
|
||||
TinkApp.GroupFilterMapPage,
|
||||
TinkApp.ActiveUser.DoFilter(TinkApp.FilterGroupSetting.DoFilter()));
|
||||
// Update map page filter.
|
||||
// Reasons for which map page filter has to be updated:
|
||||
// - user activated/ deactivated a group (TINKCorpi/ TINKSms/ Konrad)
|
||||
// - user logged off
|
||||
TinkApp.GroupFilterMapPage =
|
||||
GroupFilterMapPageHelper.CreateUpdated(
|
||||
TinkApp.GroupFilterMapPage,
|
||||
TinkApp.ActiveUser.DoFilter(TinkApp.FilterGroupSetting.DoFilter()));
|
||||
|
||||
TinkApp.CenterMapToCurrentLocation = CenterMapToCurrentLocation;
|
||||
TinkApp.CenterMapToCurrentLocation = CenterMapToCurrentLocation;
|
||||
|
||||
if (IsLogToExternalFolderVisible)
|
||||
{
|
||||
// If no external folder is available do not update model value.
|
||||
TinkApp.LogToExternalFolder = LogToExternalFolderDisplayValue;
|
||||
}
|
||||
if (IsLogToExternalFolderVisible)
|
||||
{
|
||||
// If no external folder is available do not update model value.
|
||||
TinkApp.LogToExternalFolder = LogToExternalFolderDisplayValue;
|
||||
}
|
||||
|
||||
TinkApp.IsSiteCachingOn = IsSiteCachingOnDisplayValue;
|
||||
TinkApp.IsSiteCachingOn = IsSiteCachingOnDisplayValue;
|
||||
|
||||
TinkApp.MinimumLogEventLevel = m_oMinimumLogEventLevel; // Update value to be serialized.
|
||||
TinkApp.UpdateLoggingLevel(m_oMinimumLogEventLevel); // Update logging server.
|
||||
TinkApp.MinimumLogEventLevel = m_oMinimumLogEventLevel; // Update value to be serialized.
|
||||
TinkApp.UpdateLoggingLevel(m_oMinimumLogEventLevel); // Update logging server.
|
||||
|
||||
TinkApp.IsReportLevelVerbose = IsReportLevelVerbose;
|
||||
TinkApp.IsReportLevelVerbose = IsReportLevelVerbose;
|
||||
|
||||
TinkApp.LocksServices.SetActive(LocksServices.Services.Active);
|
||||
TinkApp.LocksServices.SetActive(LocksServices.Services.Active);
|
||||
|
||||
GeoloctionServicesContainer.SetActive(GeolocationServices.Active);
|
||||
GeoloctionServicesContainer.SetActive(GeolocationServices.Active);
|
||||
|
||||
TinkApp.LocksServices.SetTimeOut(TimeSpan.FromSeconds(LocksServices.ConnectTimeoutSec));
|
||||
TinkApp.LocksServices.SetTimeOut(TimeSpan.FromSeconds(LocksServices.ConnectTimeoutSec));
|
||||
|
||||
// Persist settings in case app is closed directly.
|
||||
TinkApp.Save();
|
||||
// Persist settings in case app is closed directly.
|
||||
TinkApp.Save();
|
||||
|
||||
TinkApp.UpdateConnector();
|
||||
TinkApp.UpdateConnector();
|
||||
|
||||
await m_oViewUpdateManager.StopUpdatePeridically();
|
||||
await m_oViewUpdateManager.StopUpdatePeridically();
|
||||
|
||||
Log.ForContext<SettingsPageViewModel>().Information($"{nameof(OnDisappearing)} done.");
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
await m_oViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
$"Ein unerwarteter Fehler ist aufgetreten. \r\n{l_oException.Message}",
|
||||
"OK");
|
||||
}
|
||||
}
|
||||
Log.ForContext<SettingsPageViewModel>().Information($"{nameof(OnDisappearing)} done.");
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
await m_oViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
$"Ein unerwarteter Fehler ist aufgetreten. \r\n{l_oException.Message}",
|
||||
"OK");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> True if there is an error message to display.</summary>
|
||||
/// <summary> True if there is an error message to display.</summary>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Exception which occurred getting bike information.
|
||||
/// </summary>
|
||||
protected Exception Exception { get; set; }
|
||||
/// <summary>
|
||||
/// Exception which occurred getting bike information.
|
||||
/// </summary>
|
||||
protected Exception Exception { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true debug controls are visible, false if not.
|
||||
/// </summary>
|
||||
public Permissions DebugLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Exception == null || Exception is WebConnectFailureException)
|
||||
? TinkApp.ActiveUser.DebugLevel
|
||||
: Permissions.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// If true debug controls are visible, false if not.
|
||||
/// </summary>
|
||||
public Permissions DebugLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Exception == null || Exception is WebConnectFailureException)
|
||||
? TinkApp.ActiveUser.DebugLevel
|
||||
: Permissions.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Empty if no user is logged in session cookie otherwise. </summary>
|
||||
public string SessionCookie => TinkApp.ActiveUser.IsLoggedIn ? TinkApp.ActiveUser.SessionCookie : "";
|
||||
/// <summary> Empty if no user is logged in session cookie otherwise. </summary>
|
||||
public string SessionCookie => TinkApp.ActiveUser.IsLoggedIn ? TinkApp.ActiveUser.SessionCookie : "";
|
||||
|
||||
/// <summary>Polling periode.</summary>
|
||||
public PollingViewModel Polling { get; }
|
||||
/// <summary>Polling periode.</summary>
|
||||
public PollingViewModel Polling { get; }
|
||||
|
||||
/// <summary> Active logging level</summary>
|
||||
public string SelectedLoggingLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oMinimumLogEventLevel.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Enum.TryParse(value, out LogEventLevel l_oNewLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
/// <summary> Active logging level</summary>
|
||||
public string SelectedLoggingLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oMinimumLogEventLevel.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Enum.TryParse(value, out LogEventLevel l_oNewLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_oMinimumLogEventLevel = l_oNewLevel;
|
||||
}
|
||||
}
|
||||
m_oMinimumLogEventLevel = l_oNewLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CenterMapToCurrentLocation { get; set; }
|
||||
public bool CenterMapToCurrentLocation { get; set; }
|
||||
|
||||
/// <summary> Holds either
|
||||
/// - a value indicating whether to use external folder (e.g. SD card)/ or internal folder for storing log-files or
|
||||
/// - is false if external folder is not available
|
||||
/// </summary>
|
||||
public bool LogToExternalFolderDisplayValue { get; set; }
|
||||
/// <summary> Holds either
|
||||
/// - a value indicating whether to use external folder (e.g. SD card)/ or internal folder for storing log-files or
|
||||
/// - is false if external folder is not available
|
||||
/// </summary>
|
||||
public bool LogToExternalFolderDisplayValue { get; set; }
|
||||
|
||||
public bool IsSiteCachingOnDisplayValue { get; set; }
|
||||
public bool IsSiteCachingOnDisplayValue { get; set; }
|
||||
|
||||
/// <summary> Holds a value indicating whether user can use external folder (e.g. SD card) for storing log-files.</summary>
|
||||
public bool IsLogToExternalFolderVisible { get; }
|
||||
/// <summary> Holds a value indicating whether user can use external folder (e.g. SD card) for storing log-files.</summary>
|
||||
public bool IsLogToExternalFolderVisible { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the logging level serilog provides.
|
||||
/// </summary>
|
||||
public List<string> LoggingLevels
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<string>
|
||||
{
|
||||
LogEventLevel.Verbose.ToString(),
|
||||
LogEventLevel.Debug.ToString(),
|
||||
LogEventLevel.Information.ToString(),
|
||||
LogEventLevel.Warning.ToString(),
|
||||
LogEventLevel.Error.ToString(),
|
||||
LogEventLevel.Fatal.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Holds the logging level serilog provides.
|
||||
/// </summary>
|
||||
public List<string> LoggingLevels
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<string>
|
||||
{
|
||||
LogEventLevel.Verbose.ToString(),
|
||||
LogEventLevel.Debug.ToString(),
|
||||
LogEventLevel.Information.ToString(),
|
||||
LogEventLevel.Warning.ToString(),
|
||||
LogEventLevel.Error.ToString(),
|
||||
LogEventLevel.Fatal.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
double expiresAfterTotalSeconds;
|
||||
double expiresAfterTotalSeconds;
|
||||
|
||||
public double ExpiresAfterTotalSeconds
|
||||
{
|
||||
get => expiresAfterTotalSeconds;
|
||||
set
|
||||
{
|
||||
if (value == expiresAfterTotalSeconds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public double ExpiresAfterTotalSeconds
|
||||
{
|
||||
get => expiresAfterTotalSeconds;
|
||||
set
|
||||
{
|
||||
if (value == expiresAfterTotalSeconds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
expiresAfterTotalSeconds = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ExpiresAfterTotalSecondsText)));
|
||||
}
|
||||
}
|
||||
expiresAfterTotalSeconds = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ExpiresAfterTotalSecondsText)));
|
||||
}
|
||||
}
|
||||
|
||||
public string ExpiresAfterTotalSecondsText
|
||||
{
|
||||
get => expiresAfterTotalSeconds.ToString("0");
|
||||
}
|
||||
public string ExpiresAfterTotalSecondsText
|
||||
{
|
||||
get => expiresAfterTotalSeconds.ToString("0");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue