diff --git a/Nuki UWP/Converter/LockStateConverter.cs b/Nuki UWP/Converter/LockStateConverter.cs new file mode 100644 index 0000000..428bc3f --- /dev/null +++ b/Nuki UWP/Converter/LockStateConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.UI.Xaml.Data; +using Nuki.Communication.API; + +namespace Nuki.Converter +{ + public class LockStateConverter : IValueConverter + { + public NukiLockState LockState { get; set; } + public bool Inverted { get; set; } + public object Convert(object value, Type targetType, object parameter, string language) + { + bool blnRet = false; + NukiLockState state; + if (Enum.TryParse(value?.ToString(), out state)) + { + blnRet = state == LockState; + + } + else { } + + if (Inverted) + blnRet = !blnRet; + return blnRet; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/Nuki UWP/Nuki.csproj b/Nuki UWP/Nuki.csproj index 8c9f299..1d5be51 100644 --- a/Nuki UWP/Nuki.csproj +++ b/Nuki UWP/Nuki.csproj @@ -114,6 +114,7 @@ App.xaml + diff --git a/Nuki UWP/Views/NukiLockHome.xaml b/Nuki UWP/Views/NukiLockHome.xaml index 76cab2f..c500e4b 100644 --- a/Nuki UWP/Views/NukiLockHome.xaml +++ b/Nuki UWP/Views/NukiLockHome.xaml @@ -22,6 +22,8 @@ + + + + + @@ -71,6 +80,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -81,6 +110,7 @@ + + diff --git a/Nuki UWP/Views/NukiLockHome.xaml.cs b/Nuki UWP/Views/NukiLockHome.xaml.cs index ac668dd..12f95e4 100644 --- a/Nuki UWP/Views/NukiLockHome.xaml.cs +++ b/Nuki UWP/Views/NukiLockHome.xaml.cs @@ -22,6 +22,30 @@ public sealed partial class NukiLockHome : UserControl public NukiLockHome() { this.InitializeComponent(); + ViewModel.PropertyChanged += ViewModel_PropertyChanged; + lockActionInProgess.Begin(); + } + + private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(ViewModel.LockState)) + { + switch (ViewModel.LockState) + { + + case Communication.API.NukiLockState.Unlocking: + + case Communication.API.NukiLockState.Locking: + + case Communication.API.NukiLockState.Unlatching: + lockActionInProgess.Begin(); + break; + default: + lockActionInProgess.Stop(); + break; + } + } + else { } } } }