using DownKyi.Models; using DownKyi.Services.Download; using DownKyi.Utils; using DownKyi.ViewModels; using DownKyi.ViewModels.Dialogs; using DownKyi.ViewModels.DownloadManager; using DownKyi.ViewModels.Settings; using DownKyi.ViewModels.Toolbox; using DownKyi.Views; using DownKyi.Views.Dialogs; using DownKyi.Views.DownloadManager; using DownKyi.Views.Settings; using DownKyi.Views.Toolbox; using Prism.Ioc; using System; using System.Collections.ObjectModel; using System.Windows; namespace DownKyi { /// /// Interaction logic for App.xaml /// public partial class App { public static ObservableCollection DownloadingList { get; set; } public static ObservableCollection DownloadedList { get; set; } // 下载服务 private IDownloadService downloadService; protected override Window CreateShell() { // 设置主题 DictionaryResource.LoadTheme("ThemeDefault"); //DictionaryResource.LoadTheme("ThemeDiy"); // 切换语言 DictionaryResource.LoadLanguage("Default"); //DictionaryResource.LoadLanguage("en_US"); // 初始化数据 DownloadingList = new ObservableCollection(); DownloadedList = new ObservableCollection(); // TODO 从数据库读取 // 启动下载服务 downloadService = new AriaDownloadService(DownloadingList, DownloadedList); downloadService.Start(); return Container.Resolve(); } protected override void OnExit(ExitEventArgs e) { // 关闭下载服务 downloadService.End(); base.OnExit(e); } protected override void RegisterTypes(IContainerRegistry containerRegistry) { // pages containerRegistry.RegisterForNavigation(ViewIndexViewModel.Tag); containerRegistry.RegisterForNavigation(ViewLoginViewModel.Tag); containerRegistry.RegisterForNavigation(ViewVideoDetailViewModel.Tag); containerRegistry.RegisterForNavigation(ViewSettingsViewModel.Tag); containerRegistry.RegisterForNavigation(ViewDownloadManagerViewModel.Tag); containerRegistry.RegisterForNavigation(ViewToolboxViewModel.Tag); containerRegistry.RegisterForNavigation(ViewUserSpaceViewModel.Tag); containerRegistry.RegisterForNavigation(ViewMySpaceViewModel.Tag); containerRegistry.RegisterForNavigation(ViewPublicFavoritesViewModel.Tag); // downloadManager pages containerRegistry.RegisterForNavigation(ViewDownloadingViewModel.Tag); containerRegistry.RegisterForNavigation(ViewDownloadFinishedViewModel.Tag); // settings pages containerRegistry.RegisterForNavigation(ViewBasicViewModel.Tag); containerRegistry.RegisterForNavigation(ViewNetworkViewModel.Tag); containerRegistry.RegisterForNavigation(ViewVideoViewModel.Tag); containerRegistry.RegisterForNavigation(ViewDanmakuViewModel.Tag); containerRegistry.RegisterForNavigation(ViewAboutViewModel.Tag); // tools pages containerRegistry.RegisterForNavigation(ViewBiliHelperViewModel.Tag); containerRegistry.RegisterForNavigation(ViewDelogoViewModel.Tag); containerRegistry.RegisterForNavigation(ViewExtractMediaViewModel.Tag); // dialogs containerRegistry.RegisterDialog(ViewDownloadSetterViewModel.Tag); containerRegistry.RegisterDialog(ViewParsingSelectorViewModel.Tag); } /// /// 异步修改绑定到UI的属性 /// /// public static void PropertyChangeAsync(Action callback) { Current.Dispatcher.Invoke(callback); } } }