Пример #1
0
 private async void OnDemoOpened(object sender, DemoEntry demoEntry)
 {
     demoEntry.LastOpenDateInUTC = DateTime.UtcNow;
     await this.ProcessDemoConfigChanges();
 }
Пример #2
0
        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);
        }