Some more small changes
This commit is contained in:
parent
afed4a3ec0
commit
f01cfca9c7
@ -19,19 +19,31 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
{
|
{
|
||||||
public partial class UserSelectorDialog : UserControl, INotifyPropertyChanged
|
public partial class UserSelectorDialog : UserControl, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public new event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
private UserId _selectedUserId;
|
private UserId _selectedUserId;
|
||||||
|
private ObservableCollection<BaseModel> _profiles;
|
||||||
|
|
||||||
public ObservableCollection<BaseModel> Profiles { get; set; }
|
public ObservableCollection<BaseModel> Profiles
|
||||||
|
{
|
||||||
|
get => _profiles;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_profiles != value)
|
||||||
|
{
|
||||||
|
_profiles = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UserSelectorDialog(ObservableCollection<BaseModel> Profiles)
|
public UserSelectorDialog(ObservableCollection<BaseModel> profiles)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.Profiles = Profiles;
|
Profiles = profiles;
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
@ -39,7 +51,7 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
|
|
||||||
private void Grid_PointerEntered(object sender, PointerEventArgs e)
|
private void Grid_PointerEntered(object sender, PointerEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Grid grid && grid.DataContext is UserProfile profile)
|
if (sender is Grid { DataContext: UserProfile profile })
|
||||||
{
|
{
|
||||||
profile.IsPointerOver = true;
|
profile.IsPointerOver = true;
|
||||||
}
|
}
|
||||||
@ -47,7 +59,7 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
|
|
||||||
private void Grid_OnPointerExited(object sender, PointerEventArgs e)
|
private void Grid_OnPointerExited(object sender, PointerEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Grid grid && grid.DataContext is UserProfile profile)
|
if (sender is Grid { DataContext: UserProfile profile })
|
||||||
{
|
{
|
||||||
profile.IsPointerOver = false;
|
profile.IsPointerOver = false;
|
||||||
}
|
}
|
||||||
@ -65,31 +77,35 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
{
|
{
|
||||||
_selectedUserId = userProfile.UserId;
|
_selectedUserId = userProfile.UserId;
|
||||||
Logger.Info?.Print(LogClass.UI, $"Selected user: {userProfile.UserId}");
|
Logger.Info?.Print(LogClass.UI, $"Selected user: {userProfile.UserId}");
|
||||||
ObservableCollection<BaseModel> newProfiles = [];
|
|
||||||
|
var newProfiles = new ObservableCollection<BaseModel>();
|
||||||
|
|
||||||
foreach (var item in Profiles)
|
foreach (var item in Profiles)
|
||||||
{
|
{
|
||||||
UserProfile originalItem = (UserProfile)item;
|
if (item is UserProfile originalItem)
|
||||||
UserProfileSft profile = new (originalItem.UserId, originalItem.Name,
|
|
||||||
originalItem.Image);
|
|
||||||
if (profile.UserId == _selectedUserId)
|
|
||||||
{
|
{
|
||||||
profile.AccountState = AccountState.Open;
|
var profile = new UserProfileSft(originalItem.UserId, originalItem.Name, originalItem.Image);
|
||||||
|
|
||||||
|
if (profile.UserId == _selectedUserId)
|
||||||
|
{
|
||||||
|
profile.AccountState = AccountState.Open;
|
||||||
|
}
|
||||||
|
|
||||||
|
newProfiles.Add(new UserProfile(profile, new NavigationDialogHost()));
|
||||||
}
|
}
|
||||||
newProfiles.Add(new UserProfile(profile, new NavigationDialogHost()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiles = newProfiles;
|
Profiles = newProfiles;
|
||||||
OnPropertyChanged(nameof(Profiles));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(UserId id, bool result)> ShowInputDialog(UserSelectorDialog content, UserProfileSft accountManagerLastOpenedUser)
|
public static async Task<(UserId Id, bool Result)> ShowInputDialog(UserSelectorDialog content, UserProfileSft accountManagerLastOpenedUser)
|
||||||
{
|
{
|
||||||
content._selectedUserId = accountManagerLastOpenedUser.UserId;
|
content._selectedUserId = accountManagerLastOpenedUser.UserId;
|
||||||
ContentDialog contentDialog = new()
|
|
||||||
|
var contentDialog = new ContentDialog
|
||||||
{
|
{
|
||||||
Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle],
|
Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle],
|
||||||
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.Continue],
|
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.Continue],
|
||||||
@ -106,9 +122,11 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
{
|
{
|
||||||
if (eventArgs.Result == ContentDialogResult.Primary)
|
if (eventArgs.Result == ContentDialogResult.Primary)
|
||||||
{
|
{
|
||||||
UserSelectorDialog view = (UserSelectorDialog)contentDialog.Content;
|
if (contentDialog.Content is UserSelectorDialog view)
|
||||||
result = view?._selectedUserId ?? UserId.Null;
|
{
|
||||||
input = true;
|
result = view._selectedUserId;
|
||||||
|
input = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user