Skip to content

Commit

Permalink
#1062 处理倍速菜单排序错误问题,可恢复默认倍速菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Feb 17, 2025
1 parent 1e21d98 commit ec1cee0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Grid>
<ListView
MaxHeight="{x:Bind DialogHeight, Mode=OneWay}"
Margin="-16,0,0,40"
Margin="-16,0,0,70"
ItemsSource="{x:Bind m_viewModel.PlaySpeedMenuItems, Mode=OneWay}"
SelectionMode="None">
<ListView.ItemTemplate>
Expand Down Expand Up @@ -55,6 +55,10 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Button
x:Name="BtnAddPlaySpeed"
Margin="0,0,5,0"
Expand All @@ -67,6 +71,7 @@
MinWidth="0.01"
Maximum="20"
Text="{x:Bind m_viewModel.AddPlaySpeedValue, Mode=TwoWay}" />
<Button Grid.Row="1" Grid.ColumnSpan="2" Click="BtnBackToDefault_OnClick" HorizontalAlignment="Stretch">恢复默认</Button>
</Grid>
</Grid>
</ContentDialog>
6 changes: 6 additions & 0 deletions src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ private void BtnAddPlaySpeed_OnTapped(object sender, TappedRoutedEventArgs e)
m_viewModel.PlaySpeedMenuItems =
new ObservableCollection<PlaySpeedMenuItem>(m_viewModel.PlaySpeedMenuItems.OrderBy(x => x.Value));
}

private void BtnBackToDefault_OnClick(object sender, RoutedEventArgs e)
{
m_viewModel.PlaySpeedMenuItems =
new ObservableCollection<PlaySpeedMenuItem>(m_playSpeedMenuService.GetDefaultPlaySpeedMenu());
}
}
}
3 changes: 2 additions & 1 deletion src/BiliLite.UWP/Services/PlaySpeedMenuService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class PlaySpeedMenuService
public PlaySpeedMenuService()
{
MenuItems = SettingService.GetValue(SettingConstants.Player.PLAY_SPEED_MENU, GetDefaultPlaySpeedMenu());
MenuItems = MenuItems.OrderBy(x => x.Value).ToList();
}

public void SetMenuItems(List<PlaySpeedMenuItem> menuItems)
Expand All @@ -26,7 +27,7 @@ public int SpeedIndexOf(double speed)
return MenuItems.FindIndex(x => x.Value == speed);
}

private List<PlaySpeedMenuItem> GetDefaultPlaySpeedMenu()
public List<PlaySpeedMenuItem> GetDefaultPlaySpeedMenu()
{
return [.. new ObservableCollection<PlaySpeedMenuItem>()
{
Expand Down

0 comments on commit ec1cee0

Please sign in to comment.