Beispiel #1
0
        public static async Task <ImmutableArray <Color> > GetColorsAsync()
        {
            var settingsStore = await OptionsHelper.GetReadonlySettingsStoreAsync();

            if (!settingsStore.CollectionExists(CollectionName))
            {
                return(ImmutableArray <Color> .Empty);
            }

            var index  = 0;
            var colors = new Color[NumberOfSavedColors];

            foreach (var name in GetColorNames())
            {
                var colorInt = 0;
                try
                {
                    // In case we ever change the values we're storing we might
                    // fail to retrieve a color. That's okay, just leave it to the default color
                    // value
                    colorInt = settingsStore.GetInt32(CollectionName, name);
                }
                catch { }

                var color = ColorHelpers.ToColor((uint)colorInt);
                colors[index++] = color;
            }

            return(colors.ToImmutableArray());
        }