diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-15 14:16:26 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-15 14:16:26 +0300 |
| commit | de5700549a5fe01862f71d452f2abe4a74996605 (patch) | |
| tree | d64cd490c7012ea96299ea891d5d7013a822e347 /Software | |
| parent | c6b01f3e683b83fb0d6bf080efbd24a9a732b9f5 (diff) | |
| download | Tango-de5700549a5fe01862f71d452f2abe4a74996605.tar.gz Tango-de5700549a5fe01862f71d452f2abe4a74996605.zip | |
Implemented PPC twine animated gif.
Sign out.
Implemented TangoInject attribute 'When Available' mode!
Diffstat (limited to 'Software')
17 files changed, 156 insertions, 27 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 67bfef2e9..171258f71 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex ef2543dd1..9349d3c16 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf 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 0892932a8..75c2b1d61 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs @@ -33,6 +33,6 @@ namespace Tango.PPC.Common.Authentication /// <summary> /// Logs-out the current logged-in user. /// </summary> - void Logout(); + void LogOut(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 1fd5fdd0a..d0f8f4c6c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -71,12 +71,16 @@ namespace Tango.PPC.Common.Connection private async void ConnectToMachine() { - Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_9600); - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); + try + { + Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_9600); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); - await MachineOperator.Disconnect(); - MachineOperator.Adapter = response.Adapter; - await MachineOperator.Connect(); + await MachineOperator.Disconnect(); + MachineOperator.Adapter = response.Adapter; + await MachineOperator.Connect(); + } + catch { } } } } 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 a259e303a..7196c9743 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; using Tango.BL; using Tango.BL.Entities; using Tango.Core; +using Tango.Core.DI; using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Navigation; namespace Tango.PPC.UI.Authentication { @@ -17,6 +19,9 @@ namespace Tango.PPC.UI.Authentication /// <seealso cref="Tango.PPC.Common.Authentication.IAuthenticationProvider" /> public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider { + [TangoInject(TangoInjectMode.WhenAvailable)] + private INavigationManager _navigation; + /// <summary> /// Occurs when the current logged-in user has changed. /// </summary> @@ -36,6 +41,11 @@ namespace Tango.PPC.UI.Authentication } } + public DefaultAuthenticationProvider() + { + + } + /// <summary> /// Performs a user login by the specified email and password. /// </summary> @@ -53,10 +63,11 @@ namespace Tango.PPC.UI.Authentication /// <summary> /// Logs-out the current logged-in user. /// </summary> - public void Logout() + public void LogOut() { CurrentUser = null; CurrentUserChanged?.Invoke(this, CurrentUser); + _navigation.NavigateTo(NavigationView.LoginView); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif Binary files differnew file mode 100644 index 000000000..3aac6d473 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 5f5fb4f7e..0fbef92a7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -30,6 +30,7 @@ namespace Tango.PPC.UI.PPCApplication public class DefaultPPCApplicationManager : ExtendedObject, IPPCApplicationManager { private List<PPCViewModel> _notifiedViewModels; + private IMachineProvider _machineProvider; /// <summary> /// Occurs when the application has started. @@ -63,6 +64,8 @@ namespace Tango.PPC.UI.PPCApplication /// </summary> public DefaultPPCApplicationManager(IMachineProvider machineProvider) { + _machineProvider = machineProvider; + if (!DesignMode) { _notifiedViewModels = new List<PPCViewModel>(); @@ -115,20 +118,17 @@ namespace Tango.PPC.UI.PPCApplication { if (loader.UserModules.Count > 0) { - loader.UserModules.LastOrDefault().Initialized += (e, f) => + if (loader.UserModules.ToList().Exists(m => !m.IsInitialized)) { - foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + loader.UserModules.LastOrDefault().Initialized += (e, f) => { - if (!_notifiedViewModels.Contains(vm)) - { - vm.OnApplicationStarted(); - _notifiedViewModels.Add(vm); - } - } - - ModulesInitialized?.Invoke(this, new EventArgs()); - machineProvider.Init(); - }; + FinalizeModuleInitialization(); + }; + } + else + { + FinalizeModuleInitialization(); + } } }; }); @@ -136,6 +136,21 @@ namespace Tango.PPC.UI.PPCApplication } } + private void FinalizeModuleInitialization() + { + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + { + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } + } + + ModulesInitialized?.Invoke(this, new EventArgs()); + _machineProvider.Init(); + } + /// <summary> /// Shutdown the application. /// </summary> 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 a8c80c3f7..cc5eed54f 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 @@ -323,6 +323,7 @@ <Link>Tango.ColorLib.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Resource Include="Images\Twine_Loading_GIF.gif" /> <Resource Include="Images\GlobalStatus\standby.png" /> <Resource Include="Images\GlobalStatus\dyeing.png" /> <Resource Include="Images\preloader_rectangles.gif" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 062ade9cf..268f42ce9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -74,6 +74,11 @@ namespace Tango.PPC.UI.ViewModels public RelayCommand StopPrintingCommand { get; set; } /// <summary> + /// Gets or sets the sign-out command. + /// </summary> + public RelayCommand SignOutCommand { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="LayoutViewVM"/> class. /// </summary> public LayoutViewVM() @@ -84,6 +89,7 @@ namespace Tango.PPC.UI.ViewModels NotificationsAreaPressedCommand = new RelayCommand(OpenFirstNotificationOrDisplayAll); StopPrintingCommand = new RelayCommand(StopPrinting); + SignOutCommand = new RelayCommand(SignOut); } private void StopPrinting() @@ -162,6 +168,15 @@ namespace Tango.PPC.UI.ViewModels } /// <summary> + /// Represents an event that is raised when the sign-out operation is complete. + /// </summary> + private void SignOut() + { + AuthenticationProvider.LogOut(); + IsMenuOpened = false; + } + + /// <summary> /// Opens the first notification or display all. /// </summary> private void OpenFirstNotificationOrDisplayAll() 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 dd54873ce..022efd9b8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -54,7 +54,15 @@ namespace Tango.PPC.UI.ViewModels public override void OnApplicationStarted() { + AuthenticationProvider.CurrentUserChanged += AuthenticationProvider_CurrentUserChanged; + } + private void AuthenticationProvider_CurrentUserChanged(object sender, BL.Entities.User user) + { + if (user == null) + { + Password = String.Empty; + } } private void Login() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 89e199ed1..3aa6e0118 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -85,7 +85,7 @@ <StackPanel DockPanel.Dock="Bottom"> <Separator Margin="0 10 0 0" Background="Gainsboro" /> - <touch:TouchButton Style="{StaticResource TangoFlatButton}"> + <touch:TouchButton Style="{StaticResource TangoFlatButton}" Command="{Binding SignOutCommand}"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <fa:ImageAwesome VerticalAlignment="Center" Icon="SignOut" Width="32" Height="32"></fa:ImageAwesome> <TextBlock FontSize="16" VerticalAlignment="Center" Margin="10 0 0 0">Sign Out</TextBlock> 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 ca7d7fb53..9e7861595 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" xmlns:fx="clr-namespace:Tango.SharedUI.Effects;assembly=Tango.SharedUI" + xmlns:gif="clr-namespace:Tango.AnimatedGif;assembly=Tango.AnimatedGif" xmlns:global="clr-namespace:Tango.PPC.UI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.UI.Views" @@ -12,7 +13,7 @@ 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"> - <Image Source="/Images/logo.png" Margin="100" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant"> + <Image gif:ImageBehavior.EnableAnimation="{Binding IsLoading}" gif:ImageBehavior.AnimatedSource="/Images/Twine_Loading_GIF.gif" Margin="100" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant"> <Image.Style> <Style TargetType="Image"> <Setter Property="RenderTransform"> @@ -45,7 +46,32 @@ </Style> </Image.Style> </Image> - <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" Margin="20" HorizontalAlignment="Center">Loading...</TextBlock> + <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" Margin="20" HorizontalAlignment="Center" Width="150"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Text" Value="Loading"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsLoading}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard x:Name="story"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Text" RepeatBehavior="5x"> + <DiscreteObjectKeyFrame KeyTime="00:00:0.2" Value="Loading." /> + <DiscreteObjectKeyFrame KeyTime="00:00:0.6" Value="Loading.." /> + <DiscreteObjectKeyFrame KeyTime="00:00:0.9" Value="Loading..." /> + <DiscreteObjectKeyFrame KeyTime="00:00:1.4" Value="Loading..." /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <RemoveStoryboard BeginStoryboardName="story" /> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> </StackPanel> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml index 027e61d08..179d1dde3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml @@ -12,7 +12,7 @@ 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"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" 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> @@ -21,9 +21,9 @@ <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}" /> - <touch:TouchCheckBox Margin="0 30 0 0">Keep me logged in.</touch:TouchCheckBox> + <touch:TouchCheckBox Margin="0 30 0 0">Keep me signed in</touch:TouchCheckBox> - <touch:TouchButton Height="60" Margin="0 30 0 0" CornerRadius="3" IsDefault="True" DelayCommand="{Binding LoginCommand}" DelayCommandDuration="00:00:0.4">LOGIN</touch:TouchButton> + <touch:TouchButton Height="80" Margin="0 150 0 0" CornerRadius="40" Width="400" IsDefault="True" DelayCommand="{Binding LoginCommand}" DelayCommandDuration="00:00:0.4">LOGIN</touch:TouchButton> <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0">Forgot password?</TextBlock> </StackPanel> diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs index 20827bca7..e79a89acd 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs @@ -341,12 +341,36 @@ namespace Tango.Core.DI foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance)) { - prop.SetValue(target, GetInstance(prop.PropertyType)); + var att = prop.GetCustomAttribute<TangoInjectAttribute>(); + + if (att.Mode == TangoInjectMode.Immediate) + { + prop.SetValue(target, GetInstance(prop.PropertyType)); + } + else + { + GetInstanceWhenAvailable(prop.PropertyType, (x) => + { + prop.SetValue(target, GetInstance(prop.PropertyType)); + }); + } } foreach (var field in type.GetFieldsWithAttribute<TangoInjectAttribute>(BindingFlags.NonPublic | BindingFlags.Instance)) { - field.SetValue(target, GetInstance(field.FieldType)); + var att = field.GetCustomAttribute<TangoInjectAttribute>(); + + if (att.Mode == TangoInjectMode.Immediate) + { + field.SetValue(target, GetInstance(field.FieldType)); + } + else + { + GetInstanceWhenAvailable(field.FieldType, (x) => + { + field.SetValue(target, GetInstance(field.FieldType)); + }); + } } } } diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs b/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs index f316347fb..b05a83769 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs @@ -9,6 +9,16 @@ namespace Tango.Core.DI [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Constructor)] public class TangoInjectAttribute : Attribute { + public TangoInjectMode Mode { get; set; } + public TangoInjectAttribute() + { + + } + + public TangoInjectAttribute(TangoInjectMode mode) + { + Mode = mode; + } } } diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs b/Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs new file mode 100644 index 000000000..7ee70b3ec --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Core.DI +{ + public enum TangoInjectMode + { + Immediate, + WhenAvailable, + } +} diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 1e70bc587..d5e03d03c 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -75,6 +75,7 @@ <Compile Include="CustomAttributes\XamlVectorAttribute.cs" /> <Compile Include="DI\ITangoIOC.cs" /> <Compile Include="DI\TangoInjectAttribute.cs" /> + <Compile Include="DI\TangoInjectMode.cs" /> <Compile Include="DI\TangoIOC.cs" /> <Compile Include="DI\TangoMessenger.cs" /> <Compile Include="EventArguments\MouseOrTouchEventArgs.cs" /> |
