private async void Picker_SelectedIndexChanged(object sender, EventArgs e) { string name = colorMethods.Items[colorMethods.SelectedIndex]; var colorMethod = _colorMethods.Single(cm => cm.Name == name); var recipe = new ColorMethod { Name = name }; await _connectionColor.InsertAsync(recipe); ColorOptions.Add(recipe); int length = ColorOptions.Count; for (int i = 0; i < length - 1; i++) { var recipeDelete = ColorOptions[0]; await _connectionColor.DeleteAsync(recipeDelete); ColorOptions.Remove(recipeDelete); } }
protected override async void OnAppearing() { await _connectionColor.CreateTableAsync <ColorMethod>(); var recipes1 = await _connectionColor.Table <ColorMethod>().ToListAsync(); ColorOptions = new ObservableCollection <ColorMethod>(recipes1); await _connectionQuality.CreateTableAsync <ColorMethod>(); var recipes2 = await _connectionQuality.Table <SavedSettings>().ToListAsync(); QualityOptions = new ObservableCollection <SavedSettings>(recipes2); if (ColorOptions.Count == 0) { var recipe1 = new ColorMethod { Name = "None" }; await _connectionColor.InsertAsync(recipe1); ColorOptions.Add(recipe1); } if (QualityOptions.Count == 0) { var recipe2 = new SavedSettings { Iterations = 500, Quality = 300 }; await _connectionQuality.InsertAsync(recipe2); QualityOptions.Add(recipe2); } int length = QualityOptions.Count; for (int i = 0; i < length - 1; i++) { var recipeDelete = QualityOptions[0]; await _connectionQuality.DeleteAsync(recipeDelete); QualityOptions.Remove(recipeDelete); } int length2 = ColorOptions.Count; for (int i = 0; i < length2 - 1; i++) { var recipeDelete = ColorOptions[0]; await _connectionColor.DeleteAsync(recipeDelete); ColorOptions.Remove(recipeDelete); } colorMethods.SelectedIndex = _options.IndexOf(ColorOptions[0].Name); stepper1.Value = QualityOptions[0].Iterations; stepper2.Value = QualityOptions[0].Quality; base.OnAppearing(); }