private void BeerStyleLabel_Click(object sender, EventArgs e) { APIHandler handler = new APIHandler(); using (var MaltDialog = new IngredientPicker("Style")) { var result = MaltDialog.ShowDialog(); if (result == DialogResult.OK) { currentRecipe.styleID = MaltDialog.selectedKey; currentRecipe.style = handler.getStyle(MaltDialog.selectedKey).name; populateGrids(); } } }
private void updateStyleSliders() { APIHandler handler = new APIHandler(); try { //OG Stuff //Style set to IPA until the new API is updated with Style endpoint style currentStyle = new style();//handler.getStyle(currentRecipe.styleID); //currentStyle.minOG = 1.056F; //currentStyle.maxOG = 1.075F; //currentStyle.minFG = 1.01F; //currentStyle.maxFG = 1.018F; //currentStyle.minABV = 5.5F; //currentStyle.maxABV = 7.5F; //currentStyle.minIBU = 40F; //currentStyle.maxIBU = 70F; //currentStyle.minColor = 6; //currentStyle.maxColor = 15; //currentStyle.minCarb = 2.2F; //currentStyle.maxCarb = 2.7F; currentStyle = handler.getStyle(currentRecipe.styleID); //Temporarily set this to IPA until we get Style into the new API //BeerStyleLabel.Text = "American IPA"; BeerStyleLabel.Text = currentStyle.name; minOGLabel.Text = "" + currentStyle.minOG; maxOGLabel.Text = "" + currentStyle.maxOG; ogSlider.Minimum = 0; ogSlider.Maximum = 100; double OGSliderAdjustmentFactor = 100 / (currentStyle.maxOG - currentStyle.minOG); int currentOGSliderPosition = (int)((currentRecipe.recipeStats.og - currentStyle.minOG) * OGSliderAdjustmentFactor); if (currentOGSliderPosition > 100) { currentOGSliderPosition = 100; } else if (currentOGSliderPosition < 0) { currentOGSliderPosition = 0; } ogSlider.Value = currentOGSliderPosition; ogSlider.Refresh(); //FG Stuff minFGLabel.Text = "" + currentStyle.minFG; maxFGLabel.Text = "" + currentStyle.maxFG; fgSlider.Minimum = 0; fgSlider.Maximum = 100; double FGSliderAdjustmentFactor = 100 / (currentStyle.maxFG - currentStyle.minFG); int currentFGSliderPosition = (int)((currentRecipe.recipeStats.fg - currentStyle.minFG) * FGSliderAdjustmentFactor); if (currentFGSliderPosition > 100) { currentFGSliderPosition = 100; } else if (currentFGSliderPosition < 0) { currentFGSliderPosition = 0; } fgSlider.Value = currentFGSliderPosition; fgSlider.Refresh(); //IBU Stuff minIBULabel.Text = "" + currentStyle.minIBU; maxIBULabel.Text = "" + currentStyle.maxIBU; ibuSlider.Minimum = 0; ibuSlider.Maximum = 100; double IBUSliderAdjustmentFactor = 100 / (currentStyle.maxIBU - currentStyle.minIBU); int currentIBUSliderPosition = (int)((currentRecipe.recipeStats.ibu - currentStyle.minIBU) * IBUSliderAdjustmentFactor); if (currentIBUSliderPosition > 100) { currentIBUSliderPosition = 100; } else if (currentIBUSliderPosition < 0) { currentIBUSliderPosition = 0; } ibuSlider.Value = currentIBUSliderPosition; ibuSlider.Refresh(); //SRM Stuff minSRMLabel.Text = "" + currentStyle.minColor; maxSRMLabel.Text = "" + currentStyle.maxColor; srmSlider.Minimum = 0; srmSlider.Maximum = 100; double SRMSliderAdjustmentFactor = 100 / (currentStyle.maxColor - currentStyle.minColor); int currentSRMSliderPosition = (int)((currentRecipe.recipeStats.srm - currentStyle.minColor) * SRMSliderAdjustmentFactor); if (currentSRMSliderPosition > 100) { currentSRMSliderPosition = 100; } else if (currentSRMSliderPosition < 0) { currentSRMSliderPosition = 0; } srmSlider.Value = currentSRMSliderPosition; srmSlider.Refresh(); //ABV Stuff minABVLabel.Text = "" + currentStyle.minABV; maxABVLabel.Text = "" + currentStyle.maxABV; abvSlider.Minimum = 0; abvSlider.Maximum = 100; double ABVSliderAdjustmentFactor = 100 / (currentStyle.maxABV - currentStyle.minABV); int currentABVSliderPosition = (int)((currentRecipe.recipeStats.abv - currentStyle.minABV) * ABVSliderAdjustmentFactor); if (currentABVSliderPosition > 100) { currentABVSliderPosition = 100; } else if (currentABVSliderPosition < 0) { currentABVSliderPosition = 0; } abvSlider.Value = currentABVSliderPosition; abvSlider.Refresh(); } catch (Exception e) { srmSlider.Value = 0; ibuSlider.Value = 0; srmSlider.Value = 0; fgSlider.Value = 0; ogSlider.Value = 0; minOGLabel.Text = "" + 000; maxOGLabel.Text = " " + 000; minFGLabel.Text = "" + 000; maxFGLabel.Text = " " + 000; minSRMLabel.Text = "" + 000; maxSRMLabel.Text = " " + 000; minABVLabel.Text = "" + 000; maxABVLabel.Text = " " + 000; minIBULabel.Text = "" + 000; maxIBULabel.Text = " " + 000; } }