Created login and error handling to get auth token. Refreshing not handled.
This commit is contained in:
@@ -9,15 +9,56 @@
|
||||
Title="{x:Static p:Resources.Title_Login}"
|
||||
Height="450"
|
||||
Width="800"
|
||||
xmlns:p="clr-namespace:BodyshopUploader.Properties">
|
||||
xmlns:p="clr-namespace:BodyshopUploader.Properties"
|
||||
xmlns:util="clr-namespace:BodyshopUploader.Utils"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||
TextElement.FontWeight="Regular"
|
||||
TextElement.FontSize="13"
|
||||
TextOptions.TextFormattingMode="Ideal"
|
||||
TextOptions.TextRenderingMode="Auto"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="{DynamicResource MaterialDesignFont}"
|
||||
Closing="Window_Closing">
|
||||
<Window.DataContext>
|
||||
<vm:LoginViewModel />
|
||||
</Window.DataContext>
|
||||
<Window.Resources>
|
||||
<util:NullVisibilityConverter x:Key="NullVisibilityConverter" />
|
||||
</Window.Resources>
|
||||
|
||||
<StackPanel>
|
||||
<Button Command="{Binding OpenMainCommand}"
|
||||
Content="{x:Static p:Resources.Login}" />
|
||||
<StackPanel Orientation="Vertical"
|
||||
HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Person"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBox materialDesign:HintAssist.Hint="{x:Static p:Resources.Username}"
|
||||
Width="300"
|
||||
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
|
||||
Text="{Binding UserName}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Key"
|
||||
VerticalAlignment="Center" />
|
||||
<PasswordBox materialDesign:HintAssist.Hint="{x:Static p:Resources.Password}"
|
||||
KeyDown="PasswordBox_KeyDown"
|
||||
PasswordChanged="PasswordBox_PasswordChanged"
|
||||
Width="300"
|
||||
Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="{Binding ErrorMsg}"
|
||||
Visibility="{Binding ErrorMsg, Converter={StaticResource NullVisibilityConverter}}" />
|
||||
|
||||
<TextBlock Text="{Binding Progress, TargetNullValue=QUE, FallbackValue=QUE2}" />
|
||||
<Button Command="{Binding LoginCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
|
||||
Content="{x:Static p:Resources.Login}"
|
||||
Style="{StaticResource MaterialDesignRaisedButton}"
|
||||
IsDefault="True"
|
||||
materialDesign:ButtonProgressAssist.Value="-1"
|
||||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="True"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Loading}" />
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
@@ -23,5 +24,43 @@ namespace BodyshopUploader.Views
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.DataContext != null)
|
||||
{ ((dynamic)this.DataContext).UserPassword = ((PasswordBox)sender).SecurePassword; }
|
||||
}
|
||||
|
||||
private void PasswordBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
var pb = sender as PasswordBox;
|
||||
|
||||
if ((Keyboard.GetKeyStates(Key.CapsLock) & KeyStates.Toggled) == KeyStates.Toggled)
|
||||
{
|
||||
if (pb.ToolTip == null)
|
||||
{
|
||||
ToolTip tt = new ToolTip();
|
||||
tt.Content = "Warning: CapsLock is on";
|
||||
tt.PlacementTarget = sender as UIElement;
|
||||
tt.Placement = PlacementMode.Right;
|
||||
pb.ToolTip = tt;
|
||||
tt.IsOpen = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentToolTip = pb.ToolTip as ToolTip;
|
||||
if (currentToolTip != null)
|
||||
{
|
||||
currentToolTip.IsOpen = false;
|
||||
}
|
||||
|
||||
pb.ToolTip = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
Application.Current.Shutdown(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user