diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-19 17:08:43 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-19 17:08:43 +0300 |
| commit | 0eca640aa38c5697739f66d1b3e565d46e615b78 (patch) | |
| tree | ec68e302b44ed4f2e624b49caf0d3977a60a867c /Software/Visual_Studio/PPC | |
| parent | 1db87b6d19c6148351b37a32e8ff2b127768e945 (diff) | |
| download | Tango-0eca640aa38c5697739f66d1b3e565d46e615b78.tar.gz Tango-0eca640aa38c5697739f66d1b3e565d46e615b78.zip | |
Improved Keyboard View.
Applies TouchPanel to PPC.
Implemented LoginView for PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC')
15 files changed, 139 insertions, 22 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs index 0fca03d49..0892932a8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs @@ -28,7 +28,7 @@ namespace Tango.PPC.Common.Authentication /// <param name="email">The email.</param> /// <param name="password">The password.</param> /// <returns></returns> - Task<User> Login(String email, String password); + User Login(String email, String password); /// <summary> /// Logs-out the current logged-in user. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs index 457aaf0ab..f5744fd21 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs @@ -13,6 +13,7 @@ namespace Tango.PPC.Common.Navigation { LoadingView, LayoutView, + LoginView, HomeModule, ShutdownView, } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Fonts.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Fonts.xaml index a65810ab9..ff3e99cbf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Fonts.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Fonts.xaml @@ -6,12 +6,10 @@ <FontFamily x:Key="TangoFlexoFontFamily">Flexo</FontFamily> <sys:Double x:Key="TangoDefaultFontSize">16</sys:Double> - <sys:Double x:Key="TangoKeyboardFontSize">20</sys:Double> <sys:Double x:Key="TangoDataGridHeaderFontSize">16</sys:Double> <sys:Double x:Key="TangoNavigationLinksFontSize">18</sys:Double> <sys:Double x:Key="TangoHeaderFontSize">30</sys:Double> + <sys:Double x:Key="TangoTitleFontSize">20</sys:Double> <sys:Double x:Key="TangoButtonFontSize">20</sys:Double> - <sys:Double x:Key="TangoMessageBoxTitleFontSize">30</sys:Double> - <sys:Double x:Key="TangoMessageBoxMessageFontSize">20</sys:Double> - + </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs index 53a37c7f5..e78eef13d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs @@ -42,14 +42,11 @@ namespace Tango.PPC.UI.Authentication /// <param name="email">The email.</param> /// <param name="password">The password.</param> /// <returns></returns> - public Task<User> Login(string email, string password) + public User Login(string email, string password) { - return Task.Factory.StartNew(() => - { - CurrentUser = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email && x.Password == password); - CurrentUserChanged?.Invoke(this, CurrentUser); - return CurrentUser; - }); + CurrentUser = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email && x.Password == password); + CurrentUserChanged?.Invoke(this, CurrentUser); + return CurrentUser; } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/user-profile.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/user-profile.png Binary files differnew file mode 100644 index 000000000..00941399d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/user-profile.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml index 57a7fa9f4..d7e392f09 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml @@ -3,6 +3,6 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:Tango.PPC.UI.Resources"> - + <sys:Double x:Key="TangoKeyboardFontSize">20</sys:Double> </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index ffe4c0799..bc6e35761 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -51,6 +51,9 @@ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="SimpleValidator, Version=0.6.1.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\SimpleValidator.0.6.1.0\lib\net40\SimpleValidator.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> @@ -114,6 +117,9 @@ <Compile Include="Views\LoadingView.xaml.cs"> <DependentUpon>LoadingView.xaml</DependentUpon> </Compile> + <Compile Include="Views\LoginView.xaml.cs"> + <DependentUpon>LoginView.xaml</DependentUpon> + </Compile> <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> @@ -153,6 +159,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\LoginView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MainView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -172,6 +182,7 @@ <DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> + <Resource Include="Images\user-profile.png" /> <Resource Include="Images\warning-test.png" /> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 486392c95..11747810f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -55,6 +55,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<LoadingViewVM>(); TangoIOC.Default.Register<MainViewVM>(); + TangoIOC.Default.Register<LoginViewVM>(); TangoIOC.Default.Register<LayoutViewVM>(); @@ -88,6 +89,14 @@ namespace Tango.PPC.UI } } + public static LoginViewVM LoginViewVM + { + get + { + return TangoIOC.Default.GetInstance<LoginViewVM>(); + } + } + public static LayoutViewVM LayoutViewVM { get diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 5bc02f829..f14fb7283 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -34,14 +34,9 @@ namespace Tango.PPC.UI.ViewModels /// <summary> /// Called when the application has been started. /// </summary> - public async override void OnApplicationStarted() + public override void OnApplicationStarted() { - ApplicationManager.ModulesInitialized += (_, __) => - { - NavigationManager.NavigateTo(NavigationView.HomeModule); - }; - - await AuthenticationProvider.Login("roy@twine-s.com", "1234"); + NavigationManager.NavigateTo(NavigationView.LoginView); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs index 6962de59d..5086fd323 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -3,15 +3,61 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.PPC.Common; +using Tango.PPC.Common.Navigation; +using SimpleValidator.Extensions; +using System.ComponentModel.DataAnnotations; namespace Tango.PPC.UI.ViewModels { public class LoginViewVM : PPCViewModel { + public RelayCommand LoginCommand { get; set; } + + private String _email; + [Required(ErrorMessage = "Email is required")] + [EmailAddress(ErrorMessage = "Please enter a valid email address")] + public String Email + { + get { return _email; } + set { _email = value; RaisePropertyChangedAuto(); } + } + + private String _password; + [Required(ErrorMessage = "Password is required")] + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + + public LoginViewVM() + { + LoginCommand = new RelayCommand(Login); + } + public override void OnApplicationStarted() { - + + } + + private void Login() + { + if (Validate()) + { + var user = AuthenticationProvider.Login(Email, Password); + + if (user == null) + { + NotificationProvider.ShowWarning("Email or password are incorrect."); + } + + ApplicationManager.ModulesInitialized += (_, __) => + { + NavigationManager.NavigateTo(NavigationView.HomeModule); + }; + } } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml index d50c42f7c..f1eecc702 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml @@ -8,7 +8,7 @@ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.UI.Views" mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="720" Background="White" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}"> + d:DesignHeight="1280" d:DesignWidth="720" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}"> <Grid> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <touch:TouchBusyIndicator IsIndeterminate="True" Value="0" Width="200" Height="200" StrokeThickness="10"></touch:TouchBusyIndicator> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml new file mode 100644 index 000000000..c70c07a43 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml @@ -0,0 +1,30 @@ +<UserControl x:Class="Tango.PPC.UI.Views.LoginView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" + xmlns:global="clr-namespace:Tango.PPC.UI" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.Views" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="720" Background="White" d:DataContext="{d:DesignInstance Type=vm:LoginViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoginViewVM}"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="350" x:Name="keyboardContainer"> + <Image Source="/Images/user-profile.png" Width="128" /> + <TextBlock Margin="0 10 0 0" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}">Login to your account</TextBlock> + + <StackPanel Margin="0 60 0 0"> + <touch:TouchTextBox Text="{Binding Email,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" Watermark="Email" KeyboardMode="Email" KeyboardAction="Next" KeyboardContainer="{Binding ElementName=keyboardContainer}" /> + <touch:TouchTextBox Text="{Binding Password,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" IsPassword="True" Margin="0 40 0 0" Watermark="Password" KeyboardMode="AlphaNumeric" KeyboardAction="Go" KeyboardContainer="{Binding ElementName=keyboardContainer}" /> + + <CheckBox Margin="0 30 0 0">Keep me logged in.</CheckBox> + + <touch:TouchButton Height="50" Margin="0 30 0 0" CornerRadius="3" IsDefault="True" Command="{Binding LoginCommand}">LOGIN</touch:TouchButton> + + <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0">Forgot password?</TextBlock> + </StackPanel> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml.cs new file mode 100644 index 000000000..65e9af1ff --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Views +{ + /// <summary> + /// Interaction logic for LoginView.xaml + /// </summary> + public partial class LoginView : UserControl + { + public LoginView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 88515de8e..0f16168fe 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -30,6 +30,7 @@ <controls:NavigationControl TransitionAlwaysFades="True" TransitionType="Zoom" x:Name="NavigationControl" x:FieldModifier="public" KeepElementsAttached="True"> <local:LoadingView></local:LoadingView> + <local:LoginView></local:LoginView> <local:LayoutView></local:LayoutView> </controls:NavigationControl> </touch:TouchPanel> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config index 70668c3ed..586444936 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/packages.config @@ -5,6 +5,7 @@ <package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net46" /> <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" /> <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" /> + <package id="SimpleValidator" version="0.6.1.0" targetFramework="net46" /> <package id="System.Data.SQLite" version="1.0.108.0" targetFramework="net46" /> <package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" /> <package id="System.Data.SQLite.EF6" version="1.0.108.0" targetFramework="net46" /> |
