-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using FzLib; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using SimpleFFmpegGUI.WPF.Model; | ||
using System; | ||
using System.Collections; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
|
||
namespace SimpleFFmpegGUI.WPF.ViewModels | ||
{ | ||
public partial class TasksPageViewModel : ViewModelBase | ||
{ | ||
public TasksPageViewModel(AllTasks allTasks) | ||
{ | ||
AllTasks = allTasks; | ||
AllTasks.PropertyChanged += AllTasks_PropertyChanged; | ||
RefreshPages(); | ||
} | ||
|
||
private void AllTasks_PropertyChanged(object sender, PropertyChangedEventArgs e) | ||
{ | ||
RefreshPages(); | ||
} | ||
|
||
[RelayCommand] | ||
private void RefreshPages() | ||
{ | ||
var pages = Enumerable.Range(0, AllTasks.PageCount) | ||
.Select(p => new | ||
{ | ||
Label = "第" + (p + 1) + "页", | ||
Value = p, | ||
Value1 = p + 1 | ||
}); | ||
if (Pages == null || pages.Count() != Pages.Cast<object>().Count()) | ||
{ | ||
Pages = pages.ToList(); | ||
} | ||
} | ||
|
||
[ObservableProperty] | ||
private IEnumerable pages; | ||
|
||
public AllTasks AllTasks { get; } | ||
} | ||
} |