实现下载完成页面的排序功能

croire 4 years ago
parent 384b394014
commit ab97c43a8f

@ -18,12 +18,34 @@ namespace DownKyi.ViewModels.DownloadManager
set => SetProperty(ref downloadedList, value);
}
private int finishedSortBy;
public int FinishedSortBy
{
get => finishedSortBy;
set => SetProperty(ref finishedSortBy, value);
}
#endregion
public ViewDownloadFinishedViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
{
// 初始化DownloadedList
DownloadedList = App.DownloadedList;
DownloadFinishedSort finishedSort = SettingsManager.GetInstance().GetDownloadFinishedSort();
switch (finishedSort)
{
case DownloadFinishedSort.DOWNLOAD:
FinishedSortBy = 0;
break;
case DownloadFinishedSort.NUMBER:
FinishedSortBy = 1;
break;
default:
FinishedSortBy = 0;
break;
}
App.SortDownloadedList(finishedSort);
}
#region 命令申明
@ -42,14 +64,20 @@ namespace DownKyi.ViewModels.DownloadManager
switch (index)
{
case 1:
case 0:
App.SortDownloadedList(DownloadFinishedSort.DOWNLOAD);
// 更新设置
SettingsManager.GetInstance().SetDownloadFinishedSort(DownloadFinishedSort.DOWNLOAD);
break;
case 2:
case 1:
App.SortDownloadedList(DownloadFinishedSort.NUMBER);
// 更新设置
SettingsManager.GetInstance().SetDownloadFinishedSort(DownloadFinishedSort.NUMBER);
break;
default:
App.SortDownloadedList(DownloadFinishedSort.DOWNLOAD);
// 更新设置
SettingsManager.GetInstance().SetDownloadFinishedSort(DownloadFinishedSort.DOWNLOAD);
break;
}
}

@ -245,14 +245,15 @@
Grid.Column="1"
Width="120"
HorizontalAlignment="Left"
VerticalAlignment="Center">
VerticalAlignment="Center"
SelectedIndex="{Binding FinishedSortBy}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding FinishedSortCommand}" CommandParameter="{Binding ElementName=nameFinishedSort, Path=SelectedIndex}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ComboBoxItem Content="{DynamicResource DownloadedSortByTime}" TabIndex="1" />
<ComboBoxItem Content="{DynamicResource DownloadedSortByOrder}" TabIndex="2" />
<ComboBoxItem Content="{DynamicResource DownloadedSortByTime}" />
<ComboBoxItem Content="{DynamicResource DownloadedSortByOrder}" />
</ComboBox>
<Button

Loading…
Cancel
Save