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 | |
| parent | 1db87b6d19c6148351b37a32e8ff2b127768e945 (diff) | |
| download | Tango-0eca640aa38c5697739f66d1b3e565d46e615b78.tar.gz Tango-0eca640aa38c5697739f66d1b3e565d46e615b78.zip | |
Improved Keyboard View.
Applies TouchPanel to PPC.
Implemented LoginView for PPC.
25 files changed, 275 insertions, 50 deletions
diff --git a/Software/Graphics/Mobile/user-profile.png b/Software/Graphics/Mobile/user-profile.png Binary files differnew file mode 100644 index 000000000..00941399d --- /dev/null +++ b/Software/Graphics/Mobile/user-profile.png 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" /> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchInput.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchInput.cs new file mode 100644 index 000000000..82d74d838 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchInput.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using Tango.Touch.Keyboard; + +namespace Tango.Touch.Controls +{ + public abstract class TouchInput : Control + { + public TouchKeyboardMode KeyboardMode + { + get { return (TouchKeyboardMode)GetValue(KeyboardModeProperty); } + set { SetValue(KeyboardModeProperty, value); } + } + public static readonly DependencyProperty KeyboardModeProperty = + DependencyProperty.Register("KeyboardMode", typeof(TouchKeyboardMode), typeof(TouchInput), new PropertyMetadata(TouchKeyboardMode.AlphaNumeric)); + + public KeyboardActionKeyMode KeyboardAction + { + get { return (KeyboardActionKeyMode)GetValue(KeyboardActionProperty); } + set { SetValue(KeyboardActionProperty, value); } + } + public static readonly DependencyProperty KeyboardActionProperty = + DependencyProperty.Register("KeyboardAction", typeof(KeyboardActionKeyMode), typeof(TouchInput), new PropertyMetadata(KeyboardActionKeyMode.Next)); + + public FrameworkElement KeyboardContainer + { + get { return (FrameworkElement)GetValue(KeyboardContainerProperty); } + set { SetValue(KeyboardContainerProperty, value); } + } + public static readonly DependencyProperty KeyboardContainerProperty = + DependencyProperty.Register("KeyboardContainer", typeof(FrameworkElement), typeof(TouchInput), new PropertyMetadata(null)); + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs index c69fd17ed..8a7c907c9 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs @@ -12,10 +12,11 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Touch.Keyboard; namespace Tango.Touch.Controls { - public class TouchTextBox : Control + public class TouchTextBox : TouchInput { public String Text { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml index a4d264636..ec26d882e 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml @@ -21,15 +21,16 @@ <Style TargetType="{x:Type local:TouchTextBox}"> <Setter Property="Focusable" Value="False"></Setter> - <Setter Property="keyboard:KeyboardView.Mode" Value="AlphaNumeric"></Setter> - <Setter Property="keyboard:KeyboardView.Action" Value="Tab"></Setter> + <Setter Property="keyboard:KeyboardView.Mode" Value="{Binding RelativeSource={RelativeSource Self},Path=KeyboardMode}"></Setter> + <Setter Property="keyboard:KeyboardView.Action" Value="{Binding RelativeSource={RelativeSource Self},Path=KeyboardAction}"></Setter> + <Setter Property="keyboard:KeyboardView.Container" Value="{Binding RelativeSource={RelativeSource Self},Path=KeyboardContainer}"></Setter> <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"></Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:TouchTextBox}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" - BorderThickness="{TemplateBinding BorderThickness}"> + BorderThickness="{TemplateBinding BorderThickness}" keyboard:KeyboardView.Container="{TemplateBinding KeyboardContainer}"> <DockPanel> <Border DockPanel.Dock="Bottom" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=(Validation.HasError),Converter={StaticResource BooleanToVisibilityConverter}}"> <TextBlock FontSize="12" Foreground="{StaticResource TangoValidationErrorBrush}" Margin="0 5 0 0" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=(Validation.Errors).CurrentItem.ErrorContent}"></TextBlock> @@ -96,8 +97,8 @@ <Grid> <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="15"> <Grid> - <TextBox Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_TextBox" keyboard:KeyboardView.Mode="{TemplateBinding keyboard:KeyboardView.Mode}" keyboard:KeyboardView.Action="{TemplateBinding keyboard:KeyboardView.Action}" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></TextBox> - <PasswordBox helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_PasswordBox" keyboard:KeyboardView.Mode="{TemplateBinding keyboard:KeyboardView.Mode}" keyboard:KeyboardView.Action="{TemplateBinding keyboard:KeyboardView.Action}" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityConverter}}"></PasswordBox> + <TextBox Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_TextBox" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></TextBox> + <PasswordBox helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_PasswordBox" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityConverter}}"></PasswordBox> <TextBlock IsHitTestVisible="False" Text="{TemplateBinding Watermark}" Foreground="{StaticResource TangoTextWatermarkBrush}"> <TextBlock.Style> <Style TargetType="TextBlock"> diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs index fb574e476..3bc6292e8 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs @@ -8,8 +8,8 @@ namespace Tango.Touch.Keyboard { public enum KeyboardActionKeyMode { - Tab, - Enter, + Next, + Go, Search, } } diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs index af18357c3..821270282 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs @@ -27,6 +27,9 @@ namespace Tango.Touch.Keyboard private TouchKeyboard keyboard; private Grid gridContent; + private FrameworkElement _lastFocusedElement; + private DateTime _lastFocusTime = DateTime.Now; + #region Properties @@ -36,7 +39,7 @@ namespace Tango.Touch.Keyboard set { SetValue(IsOpenedProperty, value); } } public static readonly DependencyProperty IsOpenedProperty = - DependencyProperty.Register("IsOpened", typeof(bool), typeof(KeyboardView), new PropertyMetadata(false)); + DependencyProperty.Register("IsOpened", typeof(bool), typeof(KeyboardView), new PropertyMetadata(false,(d,e) => (d as KeyboardView).IsOpenedChanged())); public FrameworkElement View { @@ -95,18 +98,31 @@ namespace Tango.Touch.Keyboard element.LostFocus += Element_LostFocus; } - private static void Element_LostFocus(object sender, RoutedEventArgs e) + private void IsOpenedChanged() + { + if (!IsOpened) + { + if (GetContainer(_lastFocusedElement) != null) + { + ThicknessAnimation ani = new ThicknessAnimation(); + ani.To = new Thickness(0); + ani.Duration = TimeSpan.FromSeconds(0.2); + GetContainer(_lastFocusedElement).BeginAnimation(FrameworkElement.MarginProperty, ani); + } + } + } + + private static async void Element_LostFocus(object sender, RoutedEventArgs e) { FrameworkElement element = sender as FrameworkElement; - _instance.IsOpened = false; + DateTime _last = _instance._lastFocusTime; - if (GetContainer(element) != null) + await Task.Delay(100); + + if (_last == _instance._lastFocusTime) { - ThicknessAnimation ani = new ThicknessAnimation(); - ani.To = new Thickness(0); - ani.Duration = TimeSpan.FromSeconds(0.2); - GetContainer(element).BeginAnimation(FrameworkElement.MarginProperty, ani); + _instance.IsOpened = false; } } @@ -114,9 +130,14 @@ namespace Tango.Touch.Keyboard { var element = sender as FrameworkElement; + _instance._lastFocusTime = DateTime.Now; + + _instance._lastFocusedElement = element; _instance.keyboard.ActionKeyMode = GetAction(element); _instance.keyboard.Mode = GetMode(element).Value; + _instance.keyboard.IsSpecialCharactersOn = false; + if (!_instance.IsOpened) { _instance.IsOpened = true; @@ -178,7 +199,7 @@ namespace Tango.Touch.Keyboard public static readonly DependencyProperty ActionProperty = DependencyProperty.RegisterAttached("Action", typeof(KeyboardActionKeyMode), typeof(KeyboardView), - new FrameworkPropertyMetadata(KeyboardActionKeyMode.Tab)); + new FrameworkPropertyMetadata(KeyboardActionKeyMode.Next)); /// <summary> /// Sets the Action attached property. @@ -227,7 +248,7 @@ namespace Tango.Touch.Keyboard private void OnActionKeyPressed(object sender, KeyboardActionKeyMode mode) { - if (mode == KeyboardActionKeyMode.Enter || mode == KeyboardActionKeyMode.Search) + if (mode == KeyboardActionKeyMode.Go || mode == KeyboardActionKeyMode.Search) { IsOpened = false; } diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs index ab5191fe0..39662fa46 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs @@ -63,7 +63,7 @@ namespace Tango.Touch.Keyboard set { SetValue(ActionKeyModeProperty, value); } } public static readonly DependencyProperty ActionKeyModeProperty = - DependencyProperty.Register("ActionKeyMode", typeof(KeyboardActionKeyMode), typeof(TouchKeyboard), new PropertyMetadata(KeyboardActionKeyMode.Tab, (d, e) => (d as TouchKeyboard).OnActionKeyModeChanged())); + DependencyProperty.Register("ActionKeyMode", typeof(KeyboardActionKeyMode), typeof(TouchKeyboard), new PropertyMetadata(KeyboardActionKeyMode.Next, (d, e) => (d as TouchKeyboard).OnActionKeyModeChanged())); public String ActionKeyText { @@ -428,10 +428,10 @@ namespace Tango.Touch.Keyboard { switch (ActionKeyMode) { - case KeyboardActionKeyMode.Enter: + case KeyboardActionKeyMode.Go: ActionKeyText = CurrentKeyboardDefinition.EnterText; break; - case KeyboardActionKeyMode.Tab: + case KeyboardActionKeyMode.Next: ActionKeyText = CurrentKeyboardDefinition.TabText; break; case KeyboardActionKeyMode.Search: @@ -444,10 +444,10 @@ namespace Tango.Touch.Keyboard { switch (ActionKeyMode) { - case KeyboardActionKeyMode.Enter: + case KeyboardActionKeyMode.Go: SendKeys("{ENTER}"); break; - case KeyboardActionKeyMode.Tab: + case KeyboardActionKeyMode.Next: SendKeys("{TAB}"); break; case KeyboardActionKeyMode.Search: diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml index d1bad8589..7dbaff4c7 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml @@ -360,6 +360,7 @@ <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> @@ -392,12 +393,39 @@ <RepeatButton Command="{Binding NextLanguageCommand}" Style="{StaticResource bottomButtonDots}" Grid.Column="1" Visibility="{Binding IsSpecialCharactersOn,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> <TextBlock Text="{Binding CurrentKeyboardDefinition.LanguageCode}"></TextBlock> </RepeatButton> - - <RepeatButton Command="{Binding FreeTextCommand}" CommandParameter="/" Style="{StaticResource bottomButton}" Grid.Column="2" Visibility="{Binding IsSpecialCharactersOn,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + + <RepeatButton Command="{Binding FreeTextCommand}" CommandParameter="/" Grid.Column="2"> + <RepeatButton.Style> + <Style TargetType="RepeatButton" BasedOn="{StaticResource bottomButton}"> + <Setter Property="Visibility" Value="{Binding IsSpecialCharactersOn,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=Mode}" Value="Email"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </RepeatButton.Style> <TextBlock Text="/"></TextBlock> </RepeatButton> - <RepeatButton Style="{StaticResource stretchedButton}" Grid.Column="3" Command="{Binding FreeTextCommand}" CommandParameter=" "> + <RepeatButton Command="{Binding FreeTextCommand}" CommandParameter="@" Grid.Column="2"> + <RepeatButton.Style> + <Style TargetType="RepeatButton" BasedOn="{StaticResource bottomButton}"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=Mode}" Value="Email"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=IsSpecialCharactersOn}" Value="True"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </RepeatButton.Style> + <TextBlock Text="@"></TextBlock> + </RepeatButton> + + <RepeatButton Style="{StaticResource stretchedButton}" Grid.Column="3" Command="{Binding FreeTextCommand}" CommandParameter=" "> <DockPanel Margin="20 0" Height="10"> <Rectangle VerticalAlignment="Stretch" HorizontalAlignment="Left" Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=CharactersForeground}" StrokeThickness="1" DockPanel.Dock="Left" /> <Rectangle VerticalAlignment="Stretch" HorizontalAlignment="Right" Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=CharactersForeground}" StrokeThickness="1" DockPanel.Dock="Right" /> @@ -409,7 +437,24 @@ <TextBlock Text="."></TextBlock> </RepeatButton> - <RepeatButton Style="{StaticResource bottomButton}" Grid.Column="5" Command="{Binding ActionKeyCommand}"> + <RepeatButton Command="{Binding FreeTextCommand}" CommandParameter=".com" Grid.Column="5"> + <RepeatButton.Style> + <Style TargetType="RepeatButton" BasedOn="{StaticResource bottomButtonDots}"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=Mode}" Value="Email"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=IsSpecialCharactersOn}" Value="True"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </RepeatButton.Style> + <TextBlock Text=".com"></TextBlock> + </RepeatButton> + + <RepeatButton Style="{StaticResource bottomButton}" Grid.Column="6" Command="{Binding ActionKeyCommand}"> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchKeyboard},Path=ActionKeyText}"></TextBlock> </RepeatButton> </Grid> diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs index a087ebb4d..7731d867f 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs @@ -11,6 +11,7 @@ namespace Tango.Touch.Keyboard AlphaNumeric, Integer, Float, - Alpha + Alpha, + Email } } diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 339da6e59..9b25408d7 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -57,6 +57,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Controls\MessageBoxVM.cs" /> + <Compile Include="Controls\TouchInput.cs" /> <Compile Include="Controls\TouchListBox.cs" /> <Compile Include="Controls\TouchListBoxItem.cs" /> <Compile Include="Controls\TouchTextBox.cs" /> |
