UserSelector.axaml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
  6. xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
  7. xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
  8. xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
  9. xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
  10. mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
  11. x:Class="Ryujinx.Ava.Ui.Controls.UserSelector">
  12. <UserControl.Resources>
  13. <controls:BitmapArrayValueConverter x:Key="ByteImage" />
  14. </UserControl.Resources>
  15. <Design.DataContext>
  16. <viewModels:UserProfileViewModel />
  17. </Design.DataContext>
  18. <Grid HorizontalAlignment="Stretch"
  19. VerticalAlignment="Stretch">
  20. <Grid.RowDefinitions>
  21. <RowDefinition />
  22. <RowDefinition Height="Auto" />
  23. </Grid.RowDefinitions>
  24. <ListBox HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5" Items="{Binding Profiles}"
  25. DoubleTapped="ProfilesList_DoubleTapped"
  26. SelectionChanged="SelectingItemsControl_SelectionChanged">
  27. <ListBox.ItemsPanel>
  28. <ItemsPanelTemplate>
  29. <flex:FlexPanel
  30. HorizontalAlignment="Stretch"
  31. VerticalAlignment="Stretch"
  32. AlignContent="FlexStart"
  33. JustifyContent="Center" />
  34. </ItemsPanelTemplate>
  35. </ListBox.ItemsPanel>
  36. <ListBox.ItemTemplate>
  37. <DataTemplate>
  38. <Grid>
  39. <Border
  40. Margin="2"
  41. HorizontalAlignment="Stretch"
  42. VerticalAlignment="Stretch"
  43. ClipToBounds="True"
  44. CornerRadius="5">
  45. <Grid Margin="0">
  46. <Grid.RowDefinitions>
  47. <RowDefinition Height="Auto" />
  48. <RowDefinition Height="Auto" />
  49. </Grid.RowDefinitions>
  50. <Image
  51. Grid.Row="0"
  52. Margin="0"
  53. HorizontalAlignment="Stretch"
  54. VerticalAlignment="Top"
  55. Height="96" Width="96"
  56. Source="{Binding Image, Converter={StaticResource ByteImage}}" />
  57. <StackPanel
  58. Grid.Row="1"
  59. Height="30"
  60. Margin="5"
  61. HorizontalAlignment="Stretch"
  62. VerticalAlignment="Stretch">
  63. <TextBlock
  64. HorizontalAlignment="Stretch"
  65. Text="{Binding Name}"
  66. TextAlignment="Center"
  67. TextWrapping="Wrap" />
  68. </StackPanel>
  69. </Grid>
  70. </Border>
  71. <Border HorizontalAlignment="Left" VerticalAlignment="Top"
  72. IsVisible="{Binding IsOpened}"
  73. Background="LimeGreen"
  74. Width="10"
  75. Height="10"
  76. Margin="5"
  77. CornerRadius="5" />
  78. </Grid>
  79. </DataTemplate>
  80. </ListBox.ItemTemplate>
  81. </ListBox>
  82. <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,0" Spacing="10" HorizontalAlignment="Center">
  83. <Button Content="{Locale:Locale UserProfilesAddNewProfile}" Command="{Binding AddUser}" />
  84. <Button IsEnabled="{Binding IsSelectedProfiledEditable}"
  85. Content="{Locale:Locale UserProfilesEditProfile}" Command="{Binding EditUser}" />
  86. <Button IsEnabled="{Binding IsSelectedProfileDeletable}"
  87. Content="{Locale:Locale UserProfilesDeleteSelectedProfile}" Command="{Binding DeleteUser}" />
  88. </StackPanel>
  89. </Grid>
  90. </UserControl>