protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is string) { Enum.TryParse <DemoCollectionType>((string)e.Parameter, out DemoCollectionType collectionGroup); DemoCollectionGroup = collectionGroup; } this.config = await LoadDemoLauncherConfigFromFile("DemoLauncherConfig.xml"); this.AllDemos.AddRange(this.config.Entries); this.UpdateActiveDemos(); base.OnNavigatedTo(e); }
internal async static Task <DemoLauncherConfig> LoadDemoLauncherConfigFromFile(string fileName, bool enableDemosByDefault = true) { DemoLauncherConfig loadedConfig = null; IStorageItem configFile = await ApplicationData.Current.LocalFolder.TryGetItemAsync(fileName); if (configFile != null) { try { loadedConfig = await DemoLauncherConfig.FromFileAsync(configFile.Path); // Delete any demos from the persisted file list if they are no longer available foreach (var entry in loadedConfig.Entries.ToArray()) { if (!KioskExperiences.Experiences.Any(exp => exp.Attributes.Id == entry.Id)) { loadedConfig.Entries.Remove(entry); } } // Add any new demos to the persisted file list if they are not there foreach (var experience in KioskExperiences.Experiences) { DemoEntry entry = loadedConfig.Entries.FirstOrDefault(d => d.Id == experience.Attributes.Id); if (entry == null) { // New demo -> add to list loadedConfig.Entries.Add( new DemoEntry { Id = experience.Attributes.Id, Enabled = enableDemosByDefault, KioskExperience = experience }); } else { // we don't persist the experience attributes in the config file, so set it here entry.KioskExperience = experience; } } } catch (Exception) { } } if (loadedConfig == null) { loadedConfig = new DemoLauncherConfig { Entries = KioskExperiences.Experiences.Select(exp => new DemoEntry { Id = exp.Attributes.Id, Enabled = enableDemosByDefault, KioskExperience = exp }).ToList() }; } return(loadedConfig); }