forked from Mirror/Ryujinx
Avalonia: Cleanup UserEditor a bit (#3492)
This PR cleanup the UserEditor code a bit, 2 texts are added for "Name" and "User Id", because when you create a new profile, the textbox is empty without any hints. `axaml` files are autoformated too.
This commit is contained in:
parent
37b6e081da
commit
8cfec5de4b
6 changed files with 131 additions and 85 deletions
|
@ -577,5 +577,7 @@
|
||||||
"UserProfileNoImageError": "Profile image must be set",
|
"UserProfileNoImageError": "Profile image must be set",
|
||||||
"GameUpdateWindowHeading": "Updates Available for {0} [{1}]",
|
"GameUpdateWindowHeading": "Updates Available for {0} [{1}]",
|
||||||
"SettingsTabHotkeysResScaleUpHotkey": "Increase resolution:",
|
"SettingsTabHotkeysResScaleUpHotkey": "Increase resolution:",
|
||||||
"SettingsTabHotkeysResScaleDownHotkey": "Decrease resolution:"
|
"SettingsTabHotkeysResScaleDownHotkey": "Decrease resolution:",
|
||||||
|
"UserProfilesName": "Name:",
|
||||||
|
"UserProfilesUserId" : "User Id:"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,87 @@
|
||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<UserControl
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Ryujinx.Ava.Ui.Controls.UserEditor"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
mc:Ignorable="d"
|
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
Padding="0"
|
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
||||||
Margin="0"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
xmlns:models="clr-namespace:Ryujinx.Ava.Ui.Models"
|
||||||
xmlns:models="clr-namespace:Ryujinx.Ava.Ui.Models"
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
Margin="0"
|
||||||
x:Class="Ryujinx.Ava.Ui.Controls.UserEditor">
|
Padding="0"
|
||||||
|
mc:Ignorable="d">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<controls:BitmapArrayValueConverter x:Key="ByteImage" />
|
<controls:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid Margin="0">
|
<Grid Margin="0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Left">
|
<StackPanel
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Orientation="Vertical">
|
||||||
<Image
|
<Image
|
||||||
|
Name="ProfileImage"
|
||||||
|
Width="96"
|
||||||
|
Height="96"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Height="96" Width="96"
|
|
||||||
Name="ProfileImage"
|
|
||||||
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
||||||
<Button Margin="5" Content="{Locale:Locale UserProfilesChangeProfileImage}"
|
<Button
|
||||||
Name="ChangePictureButton"
|
Name="ChangePictureButton"
|
||||||
Click="ChangePictureButton_Click"
|
Margin="5"
|
||||||
HorizontalAlignment="Stretch"/>
|
HorizontalAlignment="Stretch"
|
||||||
<Button Margin="5" Content="{Locale:Locale UserProfilesSetProfileImage}"
|
Click="ChangePictureButton_Click"
|
||||||
Name="AddPictureButton"
|
Content="{Locale:Locale UserProfilesChangeProfileImage}" />
|
||||||
Click="ChangePictureButton_Click"
|
<Button
|
||||||
HorizontalAlignment="Stretch"/>
|
Name="AddPictureButton"
|
||||||
|
Margin="5"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Click="ChangePictureButton_Click"
|
||||||
|
Content="{Locale:Locale UserProfilesSetProfileImage}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="0" Orientation="Vertical" HorizontalAlignment="Stretch" Grid.Column="1" Spacing="10"
|
<StackPanel
|
||||||
Margin="5, 10">
|
Grid.Row="0"
|
||||||
<TextBox Name="NameBox" Width="300" Text="{Binding Name}" MaxLength="{Binding MaxProfileNameLength}"
|
Grid.Column="1"
|
||||||
HorizontalAlignment="Stretch" />
|
Margin="5,10"
|
||||||
<TextBlock Text="{Binding UserId}" Name="IdLabel" />
|
HorizontalAlignment="Stretch"
|
||||||
|
Orientation="Vertical"
|
||||||
|
Spacing="10">
|
||||||
|
<TextBlock Text="{Locale:Locale UserProfilesName}" />
|
||||||
|
<TextBox
|
||||||
|
Name="NameBox"
|
||||||
|
Width="300"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
MaxLength="{Binding MaxProfileNameLength}"
|
||||||
|
Text="{Binding Name}" />
|
||||||
|
<TextBlock Text="{Locale:Locale UserProfilesUserId}" />
|
||||||
|
<TextBlock Name="IdLabel" Text="{Binding UserId}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right">
|
<StackPanel
|
||||||
<Button Content="{Locale:Locale Save}" Name="SaveButton" Click="SaveButton_Click"/>
|
Grid.Row="1"
|
||||||
<Button HorizontalAlignment="Right" Content="{Locale:Locale Discard}"
|
Grid.Column="0"
|
||||||
Name="CloseButton" Click="CloseButton_Click"/>
|
Grid.ColumnSpan="2"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Spacing="10">
|
||||||
|
<Button
|
||||||
|
Name="SaveButton"
|
||||||
|
Click="SaveButton_Click"
|
||||||
|
Content="{Locale:Locale Save}" />
|
||||||
|
<Button
|
||||||
|
Name="CloseButton"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Click="CloseButton_Click"
|
||||||
|
Content="{Locale:Locale Discard}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||||
_parent?.GoBack();
|
_parent?.GoBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private async void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
DataValidationErrors.ClearErrors(NameBox);
|
DataValidationErrors.ClearErrors(NameBox);
|
||||||
bool isInvalid = false;
|
bool isInvalid = false;
|
||||||
|
@ -77,7 +77,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||||
|
|
||||||
if (TempProfile.Image == null)
|
if (TempProfile.Image == null)
|
||||||
{
|
{
|
||||||
ContentDialogHelper.CreateWarningDialog(LocaleManager.Instance["UserProfileNoImageError"], "");
|
await ContentDialogHelper.CreateWarningDialog(LocaleManager.Instance["UserProfileNoImageError"], "");
|
||||||
|
|
||||||
isInvalid = true;
|
isInvalid = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,35 @@
|
||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<UserControl
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Ryujinx.Ava.Ui.Controls.UserSelector"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
x:Class="Ryujinx.Ava.Ui.Controls.UserSelector">
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
||||||
|
d:DesignHeight="450"
|
||||||
|
d:DesignWidth="800"
|
||||||
|
mc:Ignorable="d">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<controls:BitmapArrayValueConverter x:Key="ByteImage" />
|
<controls:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<viewModels:UserProfileViewModel />
|
<viewModels:UserProfileViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<Grid HorizontalAlignment="Stretch"
|
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
VerticalAlignment="Stretch">
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListBox HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5" Items="{Binding Profiles}"
|
<ListBox
|
||||||
DoubleTapped="ProfilesList_DoubleTapped"
|
Margin="5"
|
||||||
SelectionChanged="SelectingItemsControl_SelectionChanged">
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
DoubleTapped="ProfilesList_DoubleTapped"
|
||||||
|
Items="{Binding Profiles}"
|
||||||
|
SelectionChanged="SelectingItemsControl_SelectionChanged">
|
||||||
<ListBox.ItemsPanel>
|
<ListBox.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<flex:FlexPanel
|
<flex:FlexPanel
|
||||||
|
@ -49,10 +55,11 @@
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Image
|
<Image
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
Width="96"
|
||||||
|
Height="96"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Height="96" Width="96"
|
|
||||||
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
@ -68,23 +75,34 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
<Border HorizontalAlignment="Left" VerticalAlignment="Top"
|
<Border
|
||||||
IsVisible="{Binding IsOpened}"
|
Width="10"
|
||||||
Background="LimeGreen"
|
Height="10"
|
||||||
Width="10"
|
Margin="5"
|
||||||
Height="10"
|
HorizontalAlignment="Left"
|
||||||
Margin="5"
|
VerticalAlignment="Top"
|
||||||
CornerRadius="5" />
|
Background="LimeGreen"
|
||||||
|
CornerRadius="5"
|
||||||
|
IsVisible="{Binding IsOpened}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,0" Spacing="10" HorizontalAlignment="Center">
|
<StackPanel
|
||||||
<Button Content="{Locale:Locale UserProfilesAddNewProfile}" Command="{Binding AddUser}" />
|
Grid.Row="1"
|
||||||
<Button IsEnabled="{Binding IsSelectedProfiledEditable}"
|
Margin="10,0"
|
||||||
Content="{Locale:Locale UserProfilesEditProfile}" Command="{Binding EditUser}" />
|
HorizontalAlignment="Center"
|
||||||
<Button IsEnabled="{Binding IsSelectedProfileDeletable}"
|
Orientation="Horizontal"
|
||||||
Content="{Locale:Locale UserProfilesDeleteSelectedProfile}" Command="{Binding DeleteUser}" />
|
Spacing="10">
|
||||||
|
<Button Command="{Binding AddUser}" Content="{Locale:Locale UserProfilesAddNewProfile}" />
|
||||||
|
<Button
|
||||||
|
Command="{Binding EditUser}"
|
||||||
|
Content="{Locale:Locale UserProfilesEditProfile}"
|
||||||
|
IsEnabled="{Binding IsSelectedProfiledEditable}" />
|
||||||
|
<Button
|
||||||
|
Command="{Binding DeleteUser}"
|
||||||
|
Content="{Locale:Locale UserProfilesDeleteSelectedProfile}"
|
||||||
|
IsEnabled="{Binding IsSelectedProfileDeletable}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||||
{
|
{
|
||||||
NavigatedTo(e);
|
NavigatedTo(e);
|
||||||
}, Avalonia.Interactivity.RoutingStrategies.Direct);
|
}, RoutingStrategies.Direct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,12 +29,10 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||||
{
|
{
|
||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
{
|
{
|
||||||
switch (arg.NavigationMode)
|
if (arg.NavigationMode == NavigationMode.New)
|
||||||
{
|
{
|
||||||
case NavigationMode.New:
|
_parent = (NavigationDialogHost)arg.Parameter;
|
||||||
_parent = (NavigationDialogHost)arg.Parameter;
|
ViewModel = _parent.ViewModel;
|
||||||
ViewModel = _parent.ViewModel;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
|
|
|
@ -43,11 +43,9 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsHighlightedProfileEditable =>
|
public bool IsHighlightedProfileEditable => _highlightedProfile != null;
|
||||||
_highlightedProfile != null;
|
|
||||||
|
|
||||||
public bool IsHighlightedProfileDeletable =>
|
public bool IsHighlightedProfileDeletable => _highlightedProfile != null && _highlightedProfile.UserId != AccountManager.DefaultUserId;
|
||||||
_highlightedProfile != null && _highlightedProfile.UserId != AccountManager.DefaultUserId;
|
|
||||||
|
|
||||||
public UserProfile HighlightedProfile
|
public UserProfile HighlightedProfile
|
||||||
{
|
{
|
||||||
|
@ -62,16 +60,13 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadProfiles()
|
public void LoadProfiles()
|
||||||
{
|
{
|
||||||
Profiles.Clear();
|
Profiles.Clear();
|
||||||
|
|
||||||
var profiles = _owner.AccountManager.GetAllUsers()
|
var profiles = _owner.AccountManager.GetAllUsers().OrderByDescending(x => x.AccountState == AccountState.Open);
|
||||||
.OrderByDescending(x => x.AccountState == AccountState.Open);
|
|
||||||
|
|
||||||
foreach (var profile in profiles)
|
foreach (var profile in profiles)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +89,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||||
public void AddUser()
|
public void AddUser()
|
||||||
{
|
{
|
||||||
UserProfile userProfile = null;
|
UserProfile userProfile = null;
|
||||||
|
|
||||||
_owner.Navigate(typeof(UserEditor), (this._owner, userProfile, true));
|
_owner.Navigate(typeof(UserEditor), (this._owner, userProfile, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue