UserSelector.axaml 4.8 KB

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