Skip to content

Commit

Permalink
style: set focus controls for login and add customer pages
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Camo <[email protected]>
  • Loading branch information
russkyc committed Aug 29, 2023
1 parent 0b4f405 commit a6f838b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion GroomWise.Application/ViewModels/CustomerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ private async void PopulateCollections()
{
var customers = GroomWiseDbContext!.Customers
.GetAll()
.Select(CustomerMapper.ToObservable);
.Select(CustomerMapper.ToObservable)
.OrderBy(customer => customer.FullName);
Customers = new ConcurrentObservableCollection<ObservableCustomer>(customers);
});
}
Expand Down
2 changes: 2 additions & 0 deletions GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Width="600"
d:DataContext="{d:DesignInstance viewModels:CustomerViewModel,
IsDesignTimeCreatable=True}"
FocusManager.FocusedElement="{Binding ElementName=FullNameTextBox}"
NoDecorations="True"
ResizeMode="NoResize"
SizeToContent="Height"
Expand All @@ -37,6 +38,7 @@
VerticalAlignment="Top">
<Grid>
<russkyc:ModernTextBox
Name="FullNameTextBox"
Margin="0,0,0,0"
CornerRadius="5"
HelperText="Max Length (200)"
Expand Down
2 changes: 2 additions & 0 deletions GroomWise.WPF/Views/Dialogs/LoginView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="GroomWise.Views.Dialogs.LoginView"
xmlns="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http:https://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008"
xmlns:icons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
xmlns:mc="http:https://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -14,6 +15,7 @@
d:DataContext="{d:DesignInstance viewModels:LoginViewModel,
IsDesignTimeCreatable=True}"
ExtendClientAreaToChrome="True"
FocusManager.FocusedElement="{Binding ElementName=UsernameBox}"
HideDefaultWindowTitle="True"
ResizeMode="NoResize"
TitleBarBackground="Transparent"
Expand Down
14 changes: 1 addition & 13 deletions GroomWise.WPF/Views/Dialogs/LoginView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
// without written, signed consent from the author is strictly prohibited.

using System;
using System.Linq;
using System.Windows.Input;
using GroomWise.Application.ViewModels;
using GroomWise.Infrastructure.Navigation.Interfaces;
using Injectio.Attributes;
using Russkyc.DependencyInjection.Attributes;
using Russkyc.DependencyInjection.Enums;

namespace GroomWise.Views.Dialogs;

Expand All @@ -22,22 +19,13 @@ public LoginView(LoginViewModel vm)
DataContext = vm;
InitializeComponent();
ClearFields();
UsernameBox.Focus();
}

public void ClearFields()
{
UsernameBox.Clear();
PasswordBox.Clear();
UsernameBox.Focus();
}

public void ClearFields(params string[] fields)
{
if (fields.Any(field => UsernameBox.Name.Contains(field)))
UsernameBox.Clear();
if (fields.Any(field => PasswordBox.Name.Contains(field)))
PasswordBox.Clear();
UsernameBox.Focus();
}

protected override void OnClosed(EventArgs e)
Expand Down

0 comments on commit a6f838b

Please sign in to comment.