aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Ava/UI/Views/User
diff options
context:
space:
mode:
authorMary Guillemard <mary@mary.zone>2024-03-02 12:51:05 +0100
committerGitHub <noreply@github.com>2024-03-02 12:51:05 +0100
commitec6cb0abb4b7669895b6e96fd7581c93b5abd691 (patch)
tree128c862ff5faea0b219467656d4023bee7faefb5 /src/Ryujinx.Ava/UI/Views/User
parent53b5985da6b9d7b281d9fc25b93bfd1d1918a107 (diff)
infra: Make Avalonia the default UI (#6375)
* misc: Move Ryujinx project to Ryujinx.Gtk3 This breaks release CI for now but that's fine. Signed-off-by: Mary Guillemard <mary@mary.zone> * misc: Move Ryujinx.Ava project to Ryujinx This breaks CI for now, but it's fine. Signed-off-by: Mary Guillemard <mary@mary.zone> * infra: Make Avalonia the default UI Should fix CI after the previous changes. GTK3 isn't build by the release job anymore, only by PR CI. This also ensure that the test-ava update package is still generated to allow update from the old testing channel. Signed-off-by: Mary Guillemard <mary@mary.zone> * Fix missing copy in create_app_bundle.sh Signed-off-by: Mary Guillemard <mary@mary.zone> * Fix syntax error Signed-off-by: Mary Guillemard <mary@mary.zone> --------- Signed-off-by: Mary Guillemard <mary@mary.zone>
Diffstat (limited to 'src/Ryujinx.Ava/UI/Views/User')
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml122
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml.cs165
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml113
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml.cs89
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml62
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml.cs116
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml82
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml.cs51
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml213
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs148
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml162
-rw-r--r--src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml.cs129
12 files changed, 0 insertions, 1452 deletions
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml b/src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml
deleted file mode 100644
index ab83c2cd..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml
+++ /dev/null
@@ -1,122 +0,0 @@
-<UserControl
- x:Class="Ryujinx.Ava.UI.Views.User.UserEditorView"
- xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
- xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
- Margin="0"
- MinWidth="500"
- Padding="0"
- mc:Ignorable="d"
- Focusable="True"
- x:DataType="models:TempProfile">
- <UserControl.Resources>
- <helpers:BitmapArrayValueConverter x:Key="ByteImage" />
- </UserControl.Resources>
- <Grid Margin="0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="*" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <StackPanel
- Grid.Row="0"
- Grid.Column="0"
- HorizontalAlignment="Stretch"
- Orientation="Vertical"
- Spacing="10">
- <TextBlock Text="{locale:Locale UserProfilesName}" />
- <TextBox
- Name="NameBox"
- Width="300"
- HorizontalAlignment="Stretch"
- MaxLength="{Binding MaxProfileNameLength}"
- Watermark="{locale:Locale ProfileNameSelectionWatermark}"
- Text="{Binding Name}" />
- <TextBlock Name="IdText" Text="{locale:Locale UserProfilesUserId}" />
- <TextBox
- Name="IdLabel"
- Width="300"
- HorizontalAlignment="Stretch"
- IsReadOnly="True"
- Text="{Binding UserIdString}" />
- </StackPanel>
- <StackPanel
- Grid.Row="0"
- Grid.Column="1"
- HorizontalAlignment="Right"
- VerticalAlignment="Stretch"
- Orientation="Vertical">
- <Border
- BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
- BorderThickness="1">
- <Panel>
- <ui:SymbolIcon
- FontSize="60"
- Width="96"
- Height="96"
- Margin="0"
- Foreground="{DynamicResource AppListHoverBackgroundColor}"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Top"
- Symbol="Camera" />
- <Image
- Name="ProfileImage"
- Width="96"
- Height="96"
- Margin="0"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Top"
- Source="{Binding Image, Converter={StaticResource ByteImage}}" />
- </Panel>
- </Border>
- </StackPanel>
- <StackPanel
- Grid.Row="1"
- Grid.Column="0"
- Grid.ColumnSpan="2"
- HorizontalAlignment="Left"
- Orientation="Horizontal"
- Margin="0 24 0 0"
- Spacing="10">
- <Button
- Width="50"
- MinWidth="50"
- Click="BackButton_Click">
- <ui:SymbolIcon Symbol="Back" />
- </Button>
- </StackPanel>
- <StackPanel
- Grid.Row="1"
- Grid.Column="0"
- Grid.ColumnSpan="2"
- HorizontalAlignment="Right"
- Orientation="Horizontal"
- Margin="0 24 0 0"
- Spacing="10">
- <Button
- Name="DeleteButton"
- Click="DeleteButton_Click"
- Content="{locale:Locale UserProfilesDelete}" />
- <Button
- Name="ChangePictureButton"
- Click="ChangePictureButton_Click"
- Content="{locale:Locale UserProfilesChangeProfileImage}" />
- <Button
- Name="AddPictureButton"
- Click="ChangePictureButton_Click"
- Content="{locale:Locale UserProfilesSetProfileImage}" />
- <Button
- Name="SaveButton"
- Click="SaveButton_Click"
- Content="{locale:Locale Save}" />
- </StackPanel>
- </Grid>
-</UserControl> \ No newline at end of file
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml.cs b/src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml.cs
deleted file mode 100644
index 588fa471..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserEditorView.axaml.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Data;
-using Avalonia.Interactivity;
-using FluentAvalonia.UI.Controls;
-using FluentAvalonia.UI.Navigation;
-using Ryujinx.Ava.Common.Locale;
-using Ryujinx.Ava.UI.Controls;
-using Ryujinx.Ava.UI.Helpers;
-using Ryujinx.Ava.UI.Models;
-using Ryujinx.HLE.HOS.Services.Account.Acc;
-using System;
-using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
-
-namespace Ryujinx.Ava.UI.Views.User
-{
- public partial class UserEditorView : UserControl
- {
- private NavigationDialogHost _parent;
- private UserProfile _profile;
- private bool _isNewUser;
-
- public TempProfile TempProfile { get; set; }
- public static uint MaxProfileNameLength => 0x20;
- public bool IsDeletable => _profile.UserId != AccountManager.DefaultUserId;
-
- public UserEditorView()
- {
- InitializeComponent();
- AddHandler(Frame.NavigatedToEvent, (s, e) =>
- {
- NavigatedTo(e);
- }, RoutingStrategies.Direct);
- }
-
- private void NavigatedTo(NavigationEventArgs arg)
- {
- if (Program.PreviewerDetached)
- {
- switch (arg.NavigationMode)
- {
- case NavigationMode.New:
- var (parent, profile, isNewUser) = ((NavigationDialogHost parent, UserProfile profile, bool isNewUser))arg.Parameter;
- _isNewUser = isNewUser;
- _profile = profile;
- TempProfile = new TempProfile(_profile);
-
- _parent = parent;
- break;
- }
-
- ((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - " +
- $"{(_isNewUser ? LocaleManager.Instance[LocaleKeys.UserEditorTitleCreate] : LocaleManager.Instance[LocaleKeys.UserEditorTitle])}";
-
- DataContext = TempProfile;
-
- AddPictureButton.IsVisible = _isNewUser;
- ChangePictureButton.IsVisible = !_isNewUser;
- IdLabel.IsVisible = _profile != null;
- IdText.IsVisible = _profile != null;
- if (!_isNewUser && IsDeletable)
- {
- DeleteButton.IsVisible = true;
- }
- else
- {
- DeleteButton.IsVisible = false;
- }
- }
- }
-
- private async void BackButton_Click(object sender, RoutedEventArgs e)
- {
- if (_isNewUser)
- {
- if (TempProfile.Name != String.Empty || TempProfile.Image != null)
- {
- if (await ContentDialogHelper.CreateChoiceDialog(
- LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesTitle],
- LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesMessage],
- LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesSubMessage]))
- {
- _parent?.GoBack();
- }
- }
- else
- {
- _parent?.GoBack();
- }
- }
- else
- {
- if (_profile.Name != TempProfile.Name || _profile.Image != TempProfile.Image)
- {
- if (await ContentDialogHelper.CreateChoiceDialog(
- LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesTitle],
- LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesMessage],
- LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesSubMessage]))
- {
- _parent?.GoBack();
- }
- }
- else
- {
- _parent?.GoBack();
- }
- }
- }
-
- private void DeleteButton_Click(object sender, RoutedEventArgs e)
- {
- _parent.DeleteUser(_profile);
- }
-
- private void SaveButton_Click(object sender, RoutedEventArgs e)
- {
- DataValidationErrors.ClearErrors(NameBox);
-
- if (string.IsNullOrWhiteSpace(TempProfile.Name))
- {
- DataValidationErrors.SetError(NameBox, new DataValidationException(LocaleManager.Instance[LocaleKeys.UserProfileEmptyNameError]));
-
- return;
- }
-
- if (TempProfile.Image == null)
- {
- _parent.Navigate(typeof(UserProfileImageSelectorView), (_parent, TempProfile));
-
- return;
- }
-
- if (_profile != null && !_isNewUser)
- {
- _profile.Name = TempProfile.Name;
- _profile.Image = TempProfile.Image;
- _profile.UpdateState();
- _parent.AccountManager.SetUserName(_profile.UserId, _profile.Name);
- _parent.AccountManager.SetUserImage(_profile.UserId, _profile.Image);
- }
- else if (_isNewUser)
- {
- _parent.AccountManager.AddUser(TempProfile.Name, TempProfile.Image, TempProfile.UserId);
- }
- else
- {
- return;
- }
-
- _parent?.GoBack();
- }
-
- public void SelectProfileImage()
- {
- _parent.Navigate(typeof(UserProfileImageSelectorView), (_parent, TempProfile));
- }
-
- private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
- {
- if (_profile != null || _isNewUser)
- {
- SelectProfileImage();
- }
- }
- }
-}
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml b/src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml
deleted file mode 100644
index 21dfc909..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml
+++ /dev/null
@@ -1,113 +0,0 @@
-<UserControl
- xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- Width="528"
- d:DesignWidth="578"
- d:DesignHeight="350"
- x:Class="Ryujinx.Ava.UI.Views.User.UserFirmwareAvatarSelectorView"
- xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
- xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
- xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
- x:DataType="viewModels:UserFirmwareAvatarSelectorViewModel"
- Focusable="True">
- <Design.DataContext>
- <viewModels:UserFirmwareAvatarSelectorViewModel />
- </Design.DataContext>
- <UserControl.Resources>
- <helpers:BitmapArrayValueConverter x:Key="ByteImage" />
- </UserControl.Resources>
- <Grid
- Margin="0"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <ListBox
- Grid.Row="1"
- BorderThickness="0"
- SelectedIndex="{Binding SelectedIndex}"
- Height="400"
- ItemsSource="{Binding Images}"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Center">
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel
- Orientation="Horizontal"
- Margin="0"
- HorizontalAlignment="Center" />
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- <ListBox.Styles>
- <Style Selector="ListBoxItem">
- <Setter Property="CornerRadius" Value="4" />
- <Setter Property="Width" Value="85" />
- <Setter Property="MaxWidth" Value="85" />
- <Setter Property="MinWidth" Value="85" />
- </Style>
- <Style Selector="ListBoxItem /template/ Rectangle#SelectionIndicator">
- <Setter Property="MinHeight" Value="70" />
- </Style>
- </ListBox.Styles>
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Panel
- Background="{Binding BackgroundColor}"
- Margin="5">
- <Image Source="{Binding Data, Converter={StaticResource ByteImage}}" />
- </Panel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- <StackPanel
- Grid.Row="3"
- Orientation="Horizontal"
- Spacing="10"
- Margin="0 24 0 0"
- HorizontalAlignment="Left">
- <Button
- Width="50"
- MinWidth="50"
- Height="35"
- Click="GoBack">
- <ui:SymbolIcon Symbol="Back" />
- </Button>
- </StackPanel>
- <StackPanel
- Grid.Row="3"
- Orientation="Horizontal"
- Spacing="10"
- Margin="0 24 0 0"
- HorizontalAlignment="Right">
- <ui:ColorPickerButton
- FlyoutPlacement="Top"
- IsMoreButtonVisible="False"
- UseColorPalette="False"
- UseColorTriangle="False"
- UseColorWheel="False"
- ShowAcceptDismissButtons="False"
- IsAlphaEnabled="False"
- Color="{Binding BackgroundColor, Mode=TwoWay}"
- Name="ColorButton">
- <ui:ColorPickerButton.Styles>
- <Style Selector="Grid#Root > DockPanel > Grid">
- <Setter Property="IsVisible" Value="False" />
- </Style>
- </ui:ColorPickerButton.Styles>
- </ui:ColorPickerButton>
- <Button
- Content="{locale:Locale AvatarChoose}"
- Height="35"
- Name="ChooseButton"
- Click="ChooseButton_OnClick" />
- </StackPanel>
- </Grid>
-</UserControl> \ No newline at end of file
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml.cs b/src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml.cs
deleted file mode 100644
index b6376866..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using FluentAvalonia.UI.Controls;
-using FluentAvalonia.UI.Navigation;
-using Ryujinx.Ava.UI.Controls;
-using Ryujinx.Ava.UI.Models;
-using Ryujinx.Ava.UI.ViewModels;
-using Ryujinx.HLE.FileSystem;
-using SixLabors.ImageSharp;
-using SixLabors.ImageSharp.Formats.Png;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing;
-using System.IO;
-using Image = SixLabors.ImageSharp.Image;
-
-namespace Ryujinx.Ava.UI.Views.User
-{
- public partial class UserFirmwareAvatarSelectorView : UserControl
- {
- private NavigationDialogHost _parent;
- private TempProfile _profile;
-
- public UserFirmwareAvatarSelectorView(ContentManager contentManager)
- {
- ContentManager = contentManager;
-
- DataContext = ViewModel;
-
- InitializeComponent();
- }
-
- public UserFirmwareAvatarSelectorView()
- {
- InitializeComponent();
-
- AddHandler(Frame.NavigatedToEvent, (s, e) =>
- {
- NavigatedTo(e);
- }, RoutingStrategies.Direct);
- }
-
- private void NavigatedTo(NavigationEventArgs arg)
- {
- if (Program.PreviewerDetached)
- {
- if (arg.NavigationMode == NavigationMode.New)
- {
- (_parent, _profile) = ((NavigationDialogHost, TempProfile))arg.Parameter;
- ContentManager = _parent.ContentManager;
- if (Program.PreviewerDetached)
- {
- ViewModel = new UserFirmwareAvatarSelectorViewModel();
- }
-
- DataContext = ViewModel;
- }
- }
- }
-
- public ContentManager ContentManager { get; private set; }
-
- internal UserFirmwareAvatarSelectorViewModel ViewModel { get; set; }
-
- private void GoBack(object sender, RoutedEventArgs e)
- {
- _parent.GoBack();
- }
-
- private void ChooseButton_OnClick(object sender, RoutedEventArgs e)
- {
- if (ViewModel.SelectedImage != null)
- {
- MemoryStream streamJpg = new();
- Image avatarImage = Image.Load(ViewModel.SelectedImage, new PngDecoder());
-
- avatarImage.Mutate(x => x.BackgroundColor(new Rgba32(
- ViewModel.BackgroundColor.R,
- ViewModel.BackgroundColor.G,
- ViewModel.BackgroundColor.B,
- ViewModel.BackgroundColor.A)));
- avatarImage.SaveAsJpeg(streamJpg);
-
- _profile.Image = streamJpg.ToArray();
-
- _parent.GoBack();
- }
- }
- }
-}
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml b/src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml
deleted file mode 100644
index b1786430..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml
+++ /dev/null
@@ -1,62 +0,0 @@
-<UserControl
- xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
- xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
- xmlns:viewModles="clr-namespace:Ryujinx.Ava.UI.ViewModels"
- Focusable="True"
- mc:Ignorable="d"
- x:Class="Ryujinx.Ava.UI.Views.User.UserProfileImageSelectorView"
- x:DataType="viewModles:UserProfileImageSelectorViewModel"
- Width="500"
- d:DesignWidth="500">
- <Design.DataContext>
- <viewModles:UserProfileImageSelectorViewModel />
- </Design.DataContext>
- <Grid
- HorizontalAlignment="Stretch"
- VerticalAlignment="Center">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="70" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <TextBlock
- Grid.Row="0"
- TextWrapping="Wrap"
- HorizontalAlignment="Left"
- TextAlignment="Start"
- Text="{locale:Locale ProfileImageSelectionNote}" />
- <StackPanel
- Grid.Row="2"
- Spacing="10"
- HorizontalAlignment="Left"
- Orientation="Horizontal">
- <Button
- Width="50"
- MinWidth="50"
- Click="GoBack">
- <ui:SymbolIcon Symbol="Back" />
- </Button>
- </StackPanel>
- <StackPanel
- Grid.Row="2"
- Spacing="10"
- HorizontalAlignment="Right"
- Orientation="Horizontal">
- <Button
- Name="Import"
- Click="Import_OnClick">
- <TextBlock Text="{locale:Locale ProfileImageSelectionImportImage}" />
- </Button>
- <Button
- Name="SelectFirmwareImage"
- IsEnabled="{Binding FirmwareFound}"
- Click="SelectFirmwareImage_OnClick">
- <TextBlock Text="{locale:Locale ProfileImageSelectionSelectAvatar}" />
- </Button>
- </StackPanel>
- </Grid>
-</UserControl>
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml.cs b/src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml.cs
deleted file mode 100644
index fabfaa4e..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Platform.Storage;
-using Avalonia.VisualTree;
-using FluentAvalonia.UI.Controls;
-using FluentAvalonia.UI.Navigation;
-using Ryujinx.Ava.Common.Locale;
-using Ryujinx.Ava.UI.Controls;
-using Ryujinx.Ava.UI.Models;
-using Ryujinx.Ava.UI.ViewModels;
-using Ryujinx.HLE.FileSystem;
-using SixLabors.ImageSharp;
-using SixLabors.ImageSharp.Processing;
-using System.Collections.Generic;
-using System.IO;
-using Image = SixLabors.ImageSharp.Image;
-
-namespace Ryujinx.Ava.UI.Views.User
-{
- public partial class UserProfileImageSelectorView : UserControl
- {
- private ContentManager _contentManager;
- private NavigationDialogHost _parent;
- private TempProfile _profile;
-
- internal UserProfileImageSelectorViewModel ViewModel { get; private set; }
-
- public UserProfileImageSelectorView()
- {
- InitializeComponent();
- AddHandler(Frame.NavigatedToEvent, (s, e) =>
- {
- NavigatedTo(e);
- }, RoutingStrategies.Direct);
- }
-
- private void NavigatedTo(NavigationEventArgs arg)
- {
- if (Program.PreviewerDetached)
- {
- switch (arg.NavigationMode)
- {
- case NavigationMode.New:
- (_parent, _profile) = ((NavigationDialogHost, TempProfile))arg.Parameter;
- _contentManager = _parent.ContentManager;
-
- ((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {LocaleManager.Instance[LocaleKeys.ProfileImageSelectionHeader]}";
-
- if (Program.PreviewerDetached)
- {
- DataContext = ViewModel = new UserProfileImageSelectorViewModel();
- ViewModel.FirmwareFound = _contentManager.GetCurrentFirmwareVersion() != null;
- }
-
- break;
- case NavigationMode.Back:
- if (_profile.Image != null)
- {
- _parent.GoBack();
- }
- break;
- }
- }
- }
-
- private async void Import_OnClick(object sender, RoutedEventArgs e)
- {
- var window = this.GetVisualRoot() as Window;
- var result = await window.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
- {
- AllowMultiple = false,
- FileTypeFilter = new List<FilePickerFileType>
- {
- new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
- {
- Patterns = new[] { "*.jpg", "*.jpeg", "*.png", "*.bmp" },
- AppleUniformTypeIdentifiers = new[] { "public.jpeg", "public.png", "com.microsoft.bmp" },
- MimeTypes = new[] { "image/jpeg", "image/png", "image/bmp" },
- },
- },
- });
-
- if (result.Count > 0)
- {
- _profile.Image = ProcessProfileImage(File.ReadAllBytes(result[0].Path.LocalPath));
- _parent.GoBack();
- }
- }
-
- private void GoBack(object sender, RoutedEventArgs e)
- {
- _parent.GoBack();
- }
-
- private void SelectFirmwareImage_OnClick(object sender, RoutedEventArgs e)
- {
- if (ViewModel.FirmwareFound)
- {
- _parent.Navigate(typeof(UserFirmwareAvatarSelectorView), (_parent, _profile));
- }
- }
-
- private static byte[] ProcessProfileImage(byte[] buffer)
- {
- using Image image = Image.Load(buffer);
-
- image.Mutate(x => x.Resize(256, 256));
-
- using MemoryStream streamJpg = new();
-
- image.SaveAsJpeg(streamJpg);
-
- return streamJpg.ToArray();
- }
- }
-}
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml b/src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml
deleted file mode 100644
index 3fdb4ab9..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml
+++ /dev/null
@@ -1,82 +0,0 @@
-<UserControl
- xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- d:DesignWidth="550"
- d:DesignHeight="450"
- Width="500"
- Height="400"
- xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
- xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
- xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
- x:Class="Ryujinx.Ava.UI.Views.User.UserRecovererView"
- x:DataType="viewModels:UserProfileViewModel"
- Focusable="True">
- <Design.DataContext>
- <viewModels:UserProfileViewModel />
- </Design.DataContext>
- <Grid HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch">
- <Grid.RowDefinitions>
- <RowDefinition/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
- <Border
- CornerRadius="5"
- BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
- BorderThickness="1"
- Grid.Row="0">
- <Panel>
- <ListBox
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- ItemsSource="{Binding LostProfiles}">
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Border
- Margin="2"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- ClipToBounds="True"
- CornerRadius="5">
- <Grid Margin="0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition Width="Auto"/>
- </Grid.ColumnDefinitions>
- <TextBlock
- HorizontalAlignment="Stretch"
- Text="{Binding UserId}"
- TextAlignment="Start"
- TextWrapping="Wrap" />
- <Button Grid.Column="1"
- HorizontalAlignment="Right"
- Click="Recover"
- CommandParameter="{Binding}"
- Content="{locale:Locale Recover}"/>
- </Grid>
- </Border>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- <TextBlock
- IsVisible="{Binding IsEmpty}"
- TextAlignment="Center"
- Text="{locale:Locale UserProfilesRecoverEmptyList}"/>
- </Panel>
- </Border>
- <StackPanel
- Grid.Row="1"
- Margin="0 24 0 0"
- Orientation="Horizontal">
- <Button
- Width="50"
- MinWidth="50"
- Click="GoBack">
- <ui:SymbolIcon Symbol="Back"/>
- </Button>
- </StackPanel>
- </Grid>
-</UserControl>
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml.cs b/src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml.cs
deleted file mode 100644
index 31934349..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using FluentAvalonia.UI.Controls;
-using FluentAvalonia.UI.Navigation;
-using Ryujinx.Ava.Common.Locale;
-using Ryujinx.Ava.UI.Controls;
-
-namespace Ryujinx.Ava.UI.Views.User
-{
- public partial class UserRecovererView : UserControl
- {
- private NavigationDialogHost _parent;
-
- public UserRecovererView()
- {
- InitializeComponent();
- AddHandler(Frame.NavigatedToEvent, (s, e) =>
- {
- NavigatedTo(e);
- }, RoutingStrategies.Direct);
- }
-
- private void NavigatedTo(NavigationEventArgs arg)
- {
- if (Program.PreviewerDetached)
- {
- switch (arg.NavigationMode)
- {
- case NavigationMode.New:
- var parent = (NavigationDialogHost)arg.Parameter;
-
- _parent = parent;
-
- ((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {LocaleManager.Instance[LocaleKeys.UserProfilesRecoverHeading]}";
-
- break;
- }
- }
- }
-
- private void GoBack(object sender, RoutedEventArgs e)
- {
- _parent?.GoBack();
- }
-
- private void Recover(object sender, RoutedEventArgs e)
- {
- _parent?.RecoverLostAccounts();
- }
- }
-}
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml b/src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml
deleted file mode 100644
index 8bc5125a..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml
+++ /dev/null
@@ -1,213 +0,0 @@
-<UserControl
- xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
- xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
- xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
- xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
- xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
- mc:Ignorable="d"
- d:DesignWidth="600"
- d:DesignHeight="500"
- Height="450"
- Width="550"
- x:Class="Ryujinx.Ava.UI.Views.User.UserSaveManagerView"
- x:DataType="viewModels:UserSaveManagerViewModel"
- Focusable="True">
- <Design.DataContext>
- <viewModels:UserSaveManagerViewModel />
- </Design.DataContext>
- <UserControl.Resources>
- <helpers:BitmapArrayValueConverter x:Key="ByteImage" />
- </UserControl.Resources>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Grid
- Grid.Row="0"
- HorizontalAlignment="Stretch">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
- <StackPanel
- Spacing="10"
- Orientation="Horizontal"
- HorizontalAlignment="Left"
- VerticalAlignment="Center">
- <Label Content="{locale:Locale CommonSort}" VerticalAlignment="Center" />
- <ComboBox SelectedIndex="{Binding SortIndex}" Width="100">
- <ComboBoxItem>
- <Label
- VerticalAlignment="Center"
- HorizontalContentAlignment="Left"
- Content="{locale:Locale Name}" />
- </ComboBoxItem>
- <ComboBoxItem>
- <Label
- VerticalAlignment="Center"
- HorizontalContentAlignment="Left"
- Content="{locale:Locale Size}" />
- </ComboBoxItem>
- <ComboBox.Styles>
- <Style Selector="ContentControl#ContentPresenter">
- <Setter Property="HorizontalAlignment" Value="Left" />
- </Style>
- </ComboBox.Styles>
- </ComboBox>
- <ComboBox SelectedIndex="{Binding OrderIndex}" Width="150">
- <ComboBoxItem>
- <Label
- VerticalAlignment="Center"
- HorizontalContentAlignment="Left"
- Content="{locale:Locale OrderAscending}" />
- </ComboBoxItem>
- <ComboBoxItem>
- <Label
- VerticalAlignment="Center"
- HorizontalContentAlignment="Left"
- Content="{locale:Locale OrderDescending}" />
- </ComboBoxItem>
- <ComboBox.Styles>
- <Style Selector="ContentControl#ContentPresenter">
- <Setter Property="HorizontalAlignment" Value="Left" />
- </Style>
- </ComboBox.Styles>
- </ComboBox>
- </StackPanel>
- <Grid
- Grid.Column="1"
- HorizontalAlignment="Stretch"
- Margin="10,0, 0, 0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto"/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Label Content="{locale:Locale Search}" VerticalAlignment="Center" />
- <TextBox
- Margin="5,0,0,0"
- Grid.Column="1"
- HorizontalAlignment="Stretch"
- Text="{Binding Search}" />
- </Grid>
- </Grid>
- <Border
- Grid.Row="1"
- Margin="0,5"
- BorderThickness="1"
- BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
- CornerRadius="5"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch">
- <ListBox
- Name="SaveList"
- ItemsSource="{Binding Views}"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch">
- <ListBox.Styles>
- <Style Selector="ListBoxItem">
- <Setter Property="Padding" Value="10" />
- <Setter Property="Margin" Value="5" />
- <Setter Property="CornerRadius" Value="4" />
- </Style>
- <Style Selector="ListBoxItem:selected /template/ Rectangle#SelectionIndicator">
- <Setter Property="IsVisible" Value="False" />
- </Style>
- </ListBox.Styles>
- <ListBox.ItemTemplate>
- <DataTemplate x:DataType="models:SaveModel">
- <Grid HorizontalAlignment="Stretch">
- <Grid.ColumnDefinitions>
- <ColumnDefinition />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
- <StackPanel
- Grid.Column="0"
- Orientation="Horizontal"
- Spacing="5">
- <Border
- Height="42"
- Width="42"
- Padding="10"
- BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
- BorderThickness="1"
- IsVisible="{Binding !InGameList}">
- <ui:SymbolIcon
- Symbol="Help"
- FontSize="30"
- HorizontalAlignment="Center"
- VerticalAlignment="Center" />
- </Border>
- <Image
- IsVisible="{Binding InGameList}"
- Width="42"
- Height="42"
- Source="{Binding Icon, Converter={StaticResource ByteImage}}" />
- <TextBlock
- MaxLines="3"
- Width="320"
- Margin="5"
- TextWrapping="Wrap"
- Text="{Binding Title}"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel
- Grid.Column="1"
- Spacing="10"
- HorizontalAlignment="Right"
- Orientation="Horizontal">
- <Label
- Content="{Binding SizeString}"
- IsVisible="{Binding SizeAvailable}"
- VerticalAlignment="Center"
- HorizontalAlignment="Right" />
- <Button
- VerticalAlignment="Center"
- HorizontalAlignment="Right"
- Padding="10"
- MinWidth="0"
- MinHeight="0"
- Name="OpenLocation"
- Click="OpenLocation">
- <ui:SymbolIcon
- Symbol="OpenFolder"
- HorizontalAlignment="Center"
- VerticalAlignment="Center" />
- </Button>
- <Button
- VerticalAlignment="Center"
- HorizontalAlignment="Right"
- Padding="10"
- MinWidth="0"
- MinHeight="0"
- Name="Delete"
- Click="Delete">
- <ui:SymbolIcon
- Symbol="Delete"
- HorizontalAlignment="Center"
- VerticalAlignment="Center" />
- </Button>
- </StackPanel>
- </Grid>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- </Border>
- <StackPanel
- Grid.Row="2"
- Margin="0 24 0 0"
- Orientation="Horizontal">
- <Button
- Width="50"
- MinWidth="50"
- Click="GoBack">
- <ui:SymbolIcon Symbol="Back" />
- </Button>
- </StackPanel>
- </Grid>
-</UserControl> \ No newline at end of file
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs b/src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
deleted file mode 100644
index 00a229fa..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Threading;
-using FluentAvalonia.UI.Controls;
-using FluentAvalonia.UI.Navigation;
-using LibHac;
-using LibHac.Common;
-using LibHac.Fs;
-using LibHac.Fs.Shim;
-using Ryujinx.Ava.Common;
-using Ryujinx.Ava.Common.Locale;
-using Ryujinx.Ava.UI.Controls;
-using Ryujinx.Ava.UI.Helpers;
-using Ryujinx.Ava.UI.Models;
-using Ryujinx.Ava.UI.ViewModels;
-using Ryujinx.HLE.FileSystem;
-using Ryujinx.HLE.HOS.Services.Account.Acc;
-using System;
-using System.Collections.ObjectModel;
-using System.Threading.Tasks;
-using Button = Avalonia.Controls.Button;
-using UserId = LibHac.Fs.UserId;
-
-namespace Ryujinx.Ava.UI.Views.User
-{
- public partial class UserSaveManagerView : UserControl
- {
- internal UserSaveManagerViewModel ViewModel { get; private set; }
-
- private AccountManager _accountManager;
- private HorizonClient _horizonClient;
- private VirtualFileSystem _virtualFileSystem;
- private NavigationDialogHost _parent;
-
- public UserSaveManagerView()
- {
- InitializeComponent();
- AddHandler(Frame.NavigatedToEvent, (s, e) =>
- {
- NavigatedTo(e);
- }, RoutingStrategies.Direct);
- }
-
- private void NavigatedTo(NavigationEventArgs arg)
- {
- if (Program.PreviewerDetached)
- {
- switch (arg.NavigationMode)
- {
- case NavigationMode.New:
- var (parent, accountManager, client, virtualFileSystem) = ((NavigationDialogHost parent, AccountManager accountManager, HorizonClient client, VirtualFileSystem virtualFileSystem))arg.Parameter;
- _accountManager = accountManager;
- _horizonClient = client;
- _virtualFileSystem = virtualFileSystem;
-
- _parent = parent;
- break;
- }
-
- DataContext = ViewModel = new UserSaveManagerViewModel(_accountManager);
- ((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {ViewModel.SaveManagerHeading}";
-
- Task.Run(LoadSaves);
- }
- }
-
- public void LoadSaves()
- {
- ViewModel.Saves.Clear();
- var saves = new ObservableCollection<SaveModel>();
- var saveDataFilter = SaveDataFilter.Make(
- programId: default,
- saveType: SaveDataType.Account,
- new UserId((ulong)_accountManager.LastOpenedUser.UserId.High, (ulong)_accountManager.LastOpenedUser.UserId.Low),
- saveDataId: default,
- index: default);
-
- using var saveDataIterator = new UniqueRef<SaveDataIterator>();
-
- _horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
-
- Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
-
- while (true)
- {
- saveDataIterator.Get.ReadSaveDataInfo(out long readCount, saveDataInfo).ThrowIfFailure();
-
- if (readCount == 0)
- {
- break;
- }
-
- for (int i = 0; i < readCount; i++)
- {
- var save = saveDataInfo[i];
- if (save.ProgramId.Value != 0)
- {
- var saveModel = new SaveModel(save);
- saves.Add(saveModel);
- }
- }
- }
-
- Dispatcher.UIThread.Post(() =>
- {
- ViewModel.Saves = saves;
- ViewModel.Sort();
- });
- }
-
- private void GoBack(object sender, RoutedEventArgs e)
- {
- _parent?.GoBack();
- }
-
- private void OpenLocation(object sender, RoutedEventArgs e)
- {
- if (sender is Button button)
- {
- if (button.DataContext is SaveModel saveModel)
- {
- ApplicationHelper.OpenSaveDir(saveModel.SaveId);
- }
- }
- }
-
- private async void Delete(object sender, RoutedEventArgs e)
- {
- if (sender is Button button)
- {
- if (button.DataContext is SaveModel saveModel)
- {
- var result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DeleteUserSave],
- LocaleManager.Instance[LocaleKeys.IrreversibleActionNote],
- LocaleManager.Instance[LocaleKeys.InputDialogYes],
- LocaleManager.Instance[LocaleKeys.InputDialogNo], "");
-
- if (result == UserResult.Yes)
- {
- _horizonClient.Fs.DeleteSaveData(SaveDataSpaceId.User, saveModel.SaveId);
- ViewModel.Saves.Remove(saveModel);
- ViewModel.Sort();
- }
- }
- }
- }
- }
-}
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml b/src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml
deleted file mode 100644
index 3a9de303..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml
+++ /dev/null
@@ -1,162 +0,0 @@
-<UserControl
- x:Class="Ryujinx.Ava.UI.Views.User.UserSelectorViews"
- xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
- xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
- xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
- xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
- d:DesignHeight="450"
- MinWidth="500"
- d:DesignWidth="800"
- mc:Ignorable="d"
- Focusable="True"
- x:DataType="viewModels:UserProfileViewModel">
- <UserControl.Resources>
- <helpers:BitmapArrayValueConverter x:Key="ByteImage" />
- </UserControl.Resources>
- <Design.DataContext>
- <viewModels:UserProfileViewModel />
- </Design.DataContext>
- <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Border
- CornerRadius="5"
- BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
- BorderThickness="1">
- <ListBox
- MaxHeight="300"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Center"
- SelectionChanged="ProfilesList_SelectionChanged"
- Background="Transparent"
- ItemsSource="{Binding Profiles}">
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel
- HorizontalAlignment="Left"
- VerticalAlignment="Center"
- Orientation="Horizontal"/>
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- <ListBox.Styles>
- <Style Selector="ListBoxItem">
- <Setter Property="Margin" Value="5 5 0 5" />
- <Setter Property="CornerRadius" Value="5" />
- </Style>
- <Style Selector="Rectangle#SelectionIndicator">
- <Setter Property="Opacity" Value="0" />
- </Style>
- </ListBox.Styles>
- <ListBox.DataTemplates>
- <DataTemplate
- DataType="models:UserProfile">
- <Grid
- PointerEntered="Grid_PointerEntered"
- PointerExited="Grid_OnPointerExited">
- <Border
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- ClipToBounds="True"
- CornerRadius="5"
- Background="{Binding BackgroundColor}">
- <StackPanel
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch">
- <Image
- Width="96"
- Height="96"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Top"
- Source="{Binding Image, Converter={StaticResource ByteImage}}" />
- <TextBlock
- HorizontalAlignment="Stretch"
- MaxWidth="90"
- Text="{Binding Name}"
- TextAlignment="Center"
- TextWrapping="Wrap"
- TextTrimming="CharacterEllipsis"
- MaxLines="2"
- Margin="5" />
- </StackPanel>
- </Border>
- <Border
- Margin="2"
- Height="24"
- Width="24"
- CornerRadius="12"
- HorizontalAlignment="Right"
- VerticalAlignment="Top"
- Background="{DynamicResource ThemeContentBackgroundColor}"
- IsVisible="{Binding IsPointerOver}">
- <Button
- MaxHeight="24"
- MaxWidth="24"
- MinHeight="24"
- MinWidth="24"
- CornerRadius="12"
- Padding="0"
- Click="EditUser">
- <ui:SymbolIcon Symbol="Edit" />
- </Button>
- </Border>
- </Grid>
- </DataTemplate>
- <DataTemplate
- DataType="viewModels:BaseModel">
- <Panel
- Height="118"
- Width="96">
- <Button
- MinWidth="50"
- MinHeight="50"
- MaxWidth="50"
- MaxHeight="50"
- CornerRadius="25"
- Margin="10"
- Padding="0"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"
- Click="AddUser">
- <ui:SymbolIcon Symbol="Add" />
- </Button>
- <Panel.Styles>
- <Style Selector="Panel">
- <Setter Property="Background" Value="{DynamicResource ListBoxBackground}"/>
- </Style>
- </Panel.Styles>
- </Panel>
- </DataTemplate>
- </ListBox.DataTemplates>
- </ListBox>
- </Border>
- <StackPanel
- Grid.Row="1"
- Margin="0 24 0 0"
- HorizontalAlignment="Left"
- Orientation="Horizontal"
- Spacing="10">
- <Button
- Click="ManageSaves"
- Content="{locale:Locale UserProfilesManageSaves}" />
- <Button
- Click="RecoverLostAccounts"
- Content="{locale:Locale UserProfilesRecoverLostAccounts}" />
- </StackPanel>
- <StackPanel
- Grid.Row="1"
- Margin="0 24 0 0"
- HorizontalAlignment="Right"
- Orientation="Horizontal">
- <Button
- Click="Close"
- Content="{locale:Locale UserProfilesClose}" />
- </StackPanel>
- </Grid>
-</UserControl>
diff --git a/src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml.cs b/src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml.cs
deleted file mode 100644
index fa3383aa..00000000
--- a/src/Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Input;
-using Avalonia.Interactivity;
-using FluentAvalonia.UI.Controls;
-using FluentAvalonia.UI.Navigation;
-using Ryujinx.Ava.Common.Locale;
-using Ryujinx.Ava.UI.Controls;
-using Ryujinx.Ava.UI.Models;
-using Ryujinx.Ava.UI.ViewModels;
-using Button = Avalonia.Controls.Button;
-
-namespace Ryujinx.Ava.UI.Views.User
-{
- public partial class UserSelectorViews : UserControl
- {
- private NavigationDialogHost _parent;
-
- public UserProfileViewModel ViewModel { get; set; }
-
- public UserSelectorViews()
- {
- InitializeComponent();
-
- if (Program.PreviewerDetached)
- {
- AddHandler(Frame.NavigatedToEvent, (s, e) =>
- {
- NavigatedTo(e);
- }, RoutingStrategies.Direct);
- }
- }
-
- private void NavigatedTo(NavigationEventArgs arg)
- {
- if (Program.PreviewerDetached)
- {
- if (arg.NavigationMode == NavigationMode.New)
- {
- _parent = (NavigationDialogHost)arg.Parameter;
- ViewModel = _parent.ViewModel;
- }
-
- if (arg.NavigationMode == NavigationMode.Back)
- {
- ((ContentDialog)_parent.Parent).Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle];
- }
-
- DataContext = ViewModel;
- }
- }
-
- private void Grid_PointerEntered(object sender, PointerEventArgs e)
- {
- if (sender is Grid grid)
- {
- if (grid.DataContext is UserProfile profile)
- {
- profile.IsPointerOver = true;
- }
- }
- }
-
- private void Grid_OnPointerExited(object sender, PointerEventArgs e)
- {
- if (sender is Grid grid)
- {
- if (grid.DataContext is UserProfile profile)
- {
- profile.IsPointerOver = false;
- }
- }
- }
-
- private void ProfilesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (sender is ListBox listBox)
- {
- int selectedIndex = listBox.SelectedIndex;
-
- if (selectedIndex >= 0 && selectedIndex < ViewModel.Profiles.Count)
- {
- if (ViewModel.Profiles[selectedIndex] is UserProfile userProfile)
- {
- _parent?.AccountManager?.OpenUser(userProfile.UserId);
-
- foreach (BaseModel profile in ViewModel.Profiles)
- {
- if (profile is UserProfile uProfile)
- {
- uProfile.UpdateState();
- }
- }
- }
- }
- }
- }
-
- private void AddUser(object sender, RoutedEventArgs e)
- {
- _parent.AddUser();
- }
-
- private void EditUser(object sender, RoutedEventArgs e)
- {
- if (sender is Button button)
- {
- if (button.DataContext is UserProfile userProfile)
- {
- _parent.EditUser(userProfile);
- }
- }
- }
-
- private void ManageSaves(object sender, RoutedEventArgs e)
- {
- _parent.ManageSaves();
- }
-
- private void RecoverLostAccounts(object sender, RoutedEventArgs e)
- {
- _parent.RecoverLostAccounts();
- }
-
- private void Close(object sender, RoutedEventArgs e)
- {
- ((ContentDialog)_parent.Parent).Hide();
- }
- }
-}