Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'feature/ui' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBiene committed Jan 22, 2017
2 parents cf1b1bc + c7aff03 commit 93ce082
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,4 @@ paket-files/
*.sln.iml
*.appx
*.decrypted
Nuki UWP/Nuki_StoreKey.snk
2 changes: 1 addition & 1 deletion MetroLog
9 changes: 7 additions & 2 deletions Nuki Test/Nuki Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
<ItemGroup>
<!--A reference to the entire .Net Framework and Windows SDK are automatically included-->
<None Include="project.json" />
<SDKReference Include="MSTestFramework.Universal, Version=$(UnitTestPlatformVersion)" />
<SDKReference Include="TestPlatform.Universal, Version=$(UnitTestPlatformVersion)" />
<SDKReference Include="MSTestFramework.Universal, Version=14.0" />
<SDKReference Include="TestPlatform.Universal, Version=14.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -134,6 +134,11 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
36 changes: 36 additions & 0 deletions Nuki UWP/Converter/LockStateConverter.cs
Original file line number Diff line number Diff line change
@@ -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<NukiLockState>(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();
}
}
}
1 change: 1 addition & 0 deletions Nuki UWP/Nuki.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Converter\LockStateConverter.cs" />
<Compile Include="Converter\SubstractConverter.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Converter\MultiplyConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Nuki UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="40193BoBiene.NukiSmartLock" Publisher="CN=1139BFB6-85C6-402C-A9E2-FE7C6E98DA8A" Version="1.1.25.0" />
<Identity Name="40193BoBiene.NukiSmartLock" Publisher="CN=1139BFB6-85C6-402C-A9E2-FE7C6E98DA8A" Version="1.2.29.0" />
<mp:PhoneIdentity PhoneProductId="2456611c-a2cc-4135-a062-51ba35e9ea1d" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Nuki Smart Lock</DisplayName>
Expand Down
12 changes: 12 additions & 0 deletions Nuki UWP/ViewModels/NukiLockHomePartViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ public class NukiLockHomePartViewModel : NukiLockViewModel.Part

public Visibility IsFlyoutOpen { get { return m_IsFlyoutOpen; } set { Set(ref m_IsFlyoutOpen, value); } }
public string LockRingState { get { return m_strLockRingState; } set { Set(ref m_strLockRingState, value); } }
public int SelectedFlipViewIndex {
get { return 1; }
set
{
if (value == 0)
SendLockCommand.Execute();
else if (value == 2)
SendUnlatchCommand.Execute();
RaisePropertyChanged();
}
}

public bool CriticalBattery { get { return m_blnCriticalBattery; } set { Set(ref m_blnCriticalBattery, value); } }
public NukiLockState LockState { get { return m_LockState; } set { Set(ref m_LockState, value); } }
public NukiState NukiState { get { return m_NukiState; } set { Set(ref m_NukiState, value); } }
Expand Down
53 changes: 50 additions & 3 deletions Nuki UWP/Views/NukiLockHome.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<UserControl.Resources>
<Converter:MultiplyConverter Value="0.5" x:Name="DiameterToRadius" />
<Converter:SubstractConverter Value="10" x:Name="RadiusToInnerRadius" />
<Converter:LockStateConverter LockState="Locked" x:Name="IsLocked" />
<Converter:LockStateConverter LockState="Locked" Inverted="True" x:Name="IsNotLocked" />
<Converter:SubstractConverter Value="40" x:Name="ContainerMargin" />
<Style TargetType="Button" x:Key="CommandButton">
<Setter Property="Width" Value="200"/>
Expand All @@ -31,6 +33,13 @@
<Setter Property="Margin" Value="10,10,10,0" />

</Style>
<Storyboard x:Name="lockActionInProgess" RepeatBehavior="Forever" AutoReverse="True">
<DoubleAnimation
Storyboard.TargetName="RingContainer"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.0" Duration="0:0:1"
/>
</Storyboard>

</UserControl.Resources>
<Grid>
Expand Down Expand Up @@ -71,8 +80,37 @@
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="RingState">
<VisualState>
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind ViewModel.LockState, Converter={StaticResource IsLocked}, Mode=OneWay}"></StateTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MyRingSlice.StartAngle" Value="1"></Setter>
<Setter Target="MyRingSlice.EndAngle" Value="359"></Setter>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind ViewModel.LockState, Converter={StaticResource IsNotLocked}, Mode=OneWay}"></StateTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MyRingSlice.StartAngle" Value="50"></Setter>
<Setter Target="MyRingSlice.EndAngle" Value="310"></Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<FlipView SelectedIndex="{x:Bind ViewModel.SelectedFlipViewIndex, Mode=TwoWay}">
<Grid Background="{StaticResource ResourceKey=ContrastColorBrush}" >
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Right" Margin="50" FontSize="30" Text="Lock">
<!--<TextBlock.RenderTransform>
<RotateTransform Angle="90"/>
</TextBlock.RenderTransform>-->
</TextBlock>
</Grid>
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<RelativePanel x:Name="RingContainer" VerticalAlignment="Center"
RelativePanel.AlignBottomWithPanel="True"
RelativePanel.AlignLeftWithPanel="True"
Expand All @@ -97,16 +135,17 @@
RelativePanel.AlignTopWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignLeftWithPanel="True">

<controls:RingSegment x:Name="MyRingSlice"
HorizontalAlignment="Center"
VerticalAlignment="Center" StartAngle="50" EndAngle="310"
Fill="{StaticResource ApplicationForegroundThemeBrush}"
Radius="100"
InnerRadius="90">

</controls:RingSegment>

</Grid>

</RelativePanel>
<Grid
RelativePanel.AlignBottomWithPanel="True"
Expand Down Expand Up @@ -164,5 +203,13 @@
</i:Interaction.Behaviors>

</RelativePanel>
<Grid Background="{StaticResource ResourceKey=ContrastColorBrush}" >
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="50" FontSize="30" Text="Unlock">
<!--<TextBlock.RenderTransform>
<RotateTransform Angle="270"/>
</TextBlock.RenderTransform>-->
</TextBlock>
</Grid>
</FlipView>
</Grid>
</UserControl>
24 changes: 24 additions & 0 deletions Nuki UWP/Views/NukiLockHome.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
}
}
}
4 changes: 2 additions & 2 deletions Nuki.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26020.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nuki", "Nuki UWP\Nuki.csproj", "{F2DC7D23-C393-4CAD-959F-B2CBC459FEEB}"
EndProject
Expand Down

0 comments on commit 93ce082

Please sign in to comment.