aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-15 14:16:26 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-15 14:16:26 +0300
commitde5700549a5fe01862f71d452f2abe4a74996605 (patch)
treed64cd490c7012ea96299ea891d5d7013a822e347 /Software/Visual_Studio/PPC/Tango.PPC.UI
parentc6b01f3e683b83fb0d6bf080efbd24a9a732b9f5 (diff)
downloadTango-de5700549a5fe01862f71d452f2abe4a74996605.tar.gz
Tango-de5700549a5fe01862f71d452f2abe4a74996605.zip
Implemented PPC twine animated gif.
Sign out. Implemented TangoInject attribute 'When Available' mode!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs13
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gifbin0 -> 377756 bytes
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs39
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj1
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs8
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml30
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml6
9 files changed, 95 insertions, 19 deletions
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
new file mode 100644
index 000000000..3aac6d473
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif
Binary files differ
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>