public PreferencesViewModel() { DefaultLanguages = App.AppSettings.DefaultLanguages; Terminals = App.TerminalController.Model.Terminals; DateFormats = new List <string> { "ApplicationTimeStye".GetLocalized(), "SystemTimeStye".GetLocalized() }; EditTerminalApplicationsCommand = new AsyncRelayCommand(LaunchTerminalsConfigFile); App.TerminalController.ModelChanged += ReloadTerminals; if (UserSettingsService.PreferencesSettingsService.TabsOnStartupList != null) { PagesOnStartupList = new ObservableCollection <PageOnStartupViewModel>(UserSettingsService.PreferencesSettingsService.TabsOnStartupList.Select((p) => new PageOnStartupViewModel(p))); } else { PagesOnStartupList = new ObservableCollection <PageOnStartupViewModel>(); } PagesOnStartupList.CollectionChanged += PagesOnStartupList_CollectionChanged; var recentsItem = new MenuFlyoutSubItemViewModel("JumpListRecentGroupHeader".GetLocalized()); recentsItem.Items.Add(new MenuFlyoutItemViewModel("SidebarHome".GetLocalized(), "Home".GetLocalized(), AddPageCommand)); PopulateRecentItems(recentsItem).ContinueWith(_ => { AddFlyoutItemsSource = new ReadOnlyCollection <IMenuFlyoutItem>(new IMenuFlyoutItem[] { new MenuFlyoutItemViewModel("Browse".GetLocalized(), null, AddPageCommand), recentsItem, }); }, TaskScheduler.FromCurrentSynchronizationContext()); }
private Task PopulateRecentItems(MenuFlyoutSubItemViewModel menu) { try { var recentFolders = App.RecentItemsManager.RecentFolders; // add separator if (recentFolders.Any()) { menu.Items.Add(new MenuFlyoutSeparatorViewModel()); } foreach (var recentFolder in recentFolders) { var menuItem = new MenuFlyoutItemViewModel(recentFolder.Name, recentFolder.RecentPath, AddPageCommand); menu.Items.Add(menuItem); } } catch (Exception ex) { App.Logger.Info(ex, "Could not fetch recent items"); } return(Task.CompletedTask); }
private async Task PopulateRecentItems(MenuFlyoutSubItemViewModel menu) { bool hasRecents = false; menu.Items.Add(new MenuFlyoutSeparatorViewModel()); try { var mostRecentlyUsed = StorageApplicationPermissions.MostRecentlyUsedList; foreach (AccessListEntry entry in mostRecentlyUsed.Entries) { string mruToken = entry.Token; var added = await FilesystemTasks.Wrap(async() => { IStorageItem item = await mostRecentlyUsed.GetItemAsync(mruToken, AccessCacheOptions.FastLocationsOnly); if (item.IsOfType(StorageItemTypes.Folder)) { menu.Items.Add(new MenuFlyoutItemViewModel(item.Name, string.IsNullOrEmpty(item.Path) ? entry.Metadata : item.Path, AddPageCommand)); hasRecents = true; } }); if (added == FileSystemStatusCode.Unauthorized) { // Skip item until consent is provided } // Exceptions include but are not limited to: // COMException, FileNotFoundException, ArgumentException, DirectoryNotFoundException // 0x8007016A -> The cloud file provider is not running // 0x8000000A -> The data necessary to complete this operation is not yet available // 0x80004005 -> Unspecified error // 0x80270301 -> ? else if (!added) { await FilesystemTasks.Wrap(() => { mostRecentlyUsed.Remove(mruToken); return(Task.CompletedTask); }); System.Diagnostics.Debug.WriteLine(added.ErrorCode); } } } catch (Exception ex) { App.Logger.Info(ex, "Could not fetch recent items"); } if (!hasRecents) { menu.Items.RemoveAt(menu.Items.Count - 1); } }
private async Task InitStartupSettingsRecentFoldersFlyout() { var recentsItem = new MenuFlyoutSubItemViewModel("JumpListRecentGroupHeader".GetLocalized()); recentsItem.Items.Add(new MenuFlyoutItemViewModel("Home".GetLocalized(), "Home".GetLocalized(), AddPageCommand)); await App.RecentItemsManager.UpdateRecentFoldersAsync(); // ensure recent folders aren't stale since we don't update them with a watcher await PopulateRecentItems(recentsItem).ContinueWith(_ => { AddFlyoutItemsSource = new ReadOnlyCollection <IMenuFlyoutItem>(new IMenuFlyoutItem[] { new MenuFlyoutItemViewModel("Browse".GetLocalized(), null, AddPageCommand), recentsItem, }); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public OnStartupViewModel() { if (App.AppSettings.PagesOnStartupList != null) { PagesOnStartupList = new ObservableCollection <PageOnStartupViewModel>(App.AppSettings.PagesOnStartupList.Select((p) => new PageOnStartupViewModel(p))); } else { PagesOnStartupList = new ObservableCollection <PageOnStartupViewModel>(); } PagesOnStartupList.CollectionChanged += PagesOnStartupList_CollectionChanged; var recentsItem = new MenuFlyoutSubItemViewModel("RecentLocations".GetLocalized()); recentsItem.Items.Add(new MenuFlyoutItemViewModel("SidebarHome".GetLocalized(), "Home", AddPageCommand)); PopulateRecentItems(recentsItem); addFlyoutItemsSource = new ReadOnlyCollection <IMenuFlyoutItem>(new IMenuFlyoutItem[] { new MenuFlyoutItemViewModel("Browse".GetLocalized(), null, AddPageCommand), recentsItem, }); }
public OnStartupViewModel() { if (UserSettingsService.StartupSettingsService.TabsOnStartupList != null) { PagesOnStartupList = new ObservableCollection <PageOnStartupViewModel>(UserSettingsService.StartupSettingsService.TabsOnStartupList.Select((p) => new PageOnStartupViewModel(p))); } else { PagesOnStartupList = new ObservableCollection <PageOnStartupViewModel>(); } PagesOnStartupList.CollectionChanged += PagesOnStartupList_CollectionChanged; var recentsItem = new MenuFlyoutSubItemViewModel("JumpListRecentGroupHeader".GetLocalized()); recentsItem.Items.Add(new MenuFlyoutItemViewModel("SidebarHome".GetLocalized(), "Home".GetLocalized(), AddPageCommand)); PopulateRecentItems(recentsItem).ContinueWith(_ => { AddFlyoutItemsSource = new ReadOnlyCollection <IMenuFlyoutItem>(new IMenuFlyoutItem[] { new MenuFlyoutItemViewModel("Browse".GetLocalized(), null, AddPageCommand), recentsItem, }); }, TaskScheduler.FromCurrentSynchronizationContext()); }