private async void ToolbarItem_Clicked_1(object sender, EventArgs e) { string newName = await DisplayPromptAsync("Save Settings", "Input the name for your new fractal", "OK", "Cancel", "Fractal Name"); if (newName != null && newName != "") { bool check = (riSlider.Minimum == -1); double lengthValue = lSlider.Value; if (check) { lengthValue = 1; } var recipe = new FractalRecipe { FractalName = newName, SavedComplex = ciSlider.Value, SavedLength = lengthValue, SavedReal = riSlider.Value, IsJuliaSet = check }; await _connection.InsertAsync(recipe); SavedFractals.Add(recipe); Refresh(); } }
//Gives choices of preset private async void ImageButton_Clicked_1(object sender, EventArgs e) { string[] fractalOptions = fractalList.ToArray(); string option = await DisplayActionSheet("Fractal Type", "Cancel", null, fractalOptions); bool clicked = false; if (option != "Cancel" && option != "OK" && option != "") { int setItem = fractalOptions.IndexOf(option); clicked = true; bool _continue = true; if (setItem <= integer - 1) { while (_continue) { _continue = false; string action = await DisplayActionSheet("Fractal Actions", "Cancel", null, "Set Fractal", "Info", "Advanced"); if (action == "Set Fractal") { item = setItem; await DisplayAlert("Fractal Set", "The current set fractal is: " + fractalOptions[item], "OK"); } else if (action == "Info") { await DisplayAlert("Fractal Info", "X Value (Real value on complex plane): " + varList1[setItem] + "\nY Value (Complex value on complex plane): " + varList2[setItem] + "\nSize (Length of pixel intervals): " + varList3[setItem], "OK"); _continue = true; } else if (action == "Advanced") { carouselPage.CurrentPage = carouselPage.Children[1]; riSlider.Value = varList1[setItem]; ciSlider.Value = varList2[setItem]; lSlider.Value = varList3[setItem]; } } } else { while (_continue) { _continue = false; string action = await DisplayActionSheet("Fractal Actions", "Cancel", null, "Set Fractal", "Delete", "Info", "Rename", "Advanced"); if (action == "Set Fractal") { item = setItem; await DisplayAlert("Fractal Set", "The current set fractal is: " + fractalOptions[item], "OK"); } else if (action == "Delete") { bool deleteCheck = await DisplayAlert("Delete", "Are you sure you would like to delete?", "OK", "Cancel"); if (deleteCheck) { var recipeDelete = SavedFractals[setItem - integer]; await _connection.DeleteAsync(recipeDelete); SavedFractals.Remove(recipeDelete); if (item == setItem) { item = 0; } } Refresh(); } else if (action == "Info") { await DisplayAlert("Fractal Info", "X Value (Real value on complex plane): " + SavedFractals[setItem - integer].SavedReal + "\nY Value (Complex value on complex plane): " + SavedFractals[setItem - integer].SavedComplex + "\nSize (Length of pixel intervals): " + SavedFractals[setItem - integer].SavedLength, "OK"); _continue = true; } else if (action == "Rename") { string newFractal = await DisplayPromptAsync("Rename Fractal", "What would you like to rename " + SavedFractals[setItem - integer].FractalName + "?", "OK", "Cancel", SavedFractals[setItem - integer].FractalName); if (newFractal != null && newFractal != "" && newFractal != SavedFractals[setItem - integer].FractalName) { double realCache = SavedFractals[setItem - integer].SavedReal; double complexCache = SavedFractals[setItem - integer].SavedComplex; double lengthCache = SavedFractals[setItem - integer].SavedLength; bool juliaCheck = SavedFractals[setItem - integer].IsJuliaSet; var recipe = SavedFractals[setItem - integer]; await _connection.DeleteAsync(recipe); SavedFractals.Remove(recipe); recipe = new FractalRecipe { FractalName = newFractal, SavedComplex = complexCache, SavedLength = lengthCache, SavedReal = realCache, IsJuliaSet = juliaCheck }; await _connection.InsertAsync(recipe); SavedFractals.Add(recipe); Refresh(); } } else if (action == "Advanced") { carouselPage.CurrentPage = carouselPage.Children[1]; riSlider.Value = SavedFractals[setItem - integer].SavedReal; ciSlider.Value = SavedFractals[setItem - integer].SavedComplex; lSlider.Value = SavedFractals[setItem - integer].SavedLength; } } var btn = sender as Button; btn.Command.Execute(btn.CommandParameter); } } if (clicked) { createAdvanced = false; } }