private void MaltsListView_KeyDown(object sender, KeyEventArgs e) { if (Key.Delete == e.Key) { foreach (GristPart listViewItem in ((ListView)sender).SelectedItems) { Grist.Remove(listViewItem); MessageBox.Show(String.Format("Shit, want to remove {0}. That is {1} away", listViewItem.FermentableAdjunct.Name, listViewItem.Amount)); break; } } }
private void MaltsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (MaltsListView.SelectedIndex >= Grist.Count() || MaltsListView.SelectedIndex < 0) { return; } double sum = Grist.Sum(g => g.Amount); sum -= Grist.ToArray()[MaltsListView.SelectedIndex].Amount; var sw = new SelectGrain(MaltRepo, sum, Grist.ToArray()[MaltsListView.SelectedIndex]); sw.ShowDialog(); if (sw.Result != null) { Grist.Remove((GristPart)MaltsListView.SelectedItem); Grist.Add(sw.Result); recalculateGrainBill(); } }
private void recalculateGrainBill() { var sum = Grist.Sum(g => g.Amount); if (sum != 100) { sum = -1; GrainBillSize = 0; } else { var preBoilTappOffLoss = (Volumes.PreBoilTapOff / (Volumes.PreBoilVolume + Volumes.PreBoilTapOff)); var totalGravity = GravityAlgorithms.GetTotalGravity(Volumes.PostBoilVolume, OriginalGravity); Volumes.ColdSteepVolume = 0; var l = new List <GristPart>(); foreach (var grain in Grist) { grain.GU = totalGravity * ((double)grain.Amount / 100d); if (grain.Stage == FermentableStage.ColdSteep) { grain.AmountGrams = GravityAlgorithms.GetGrainWeight(grain.GU, grain.FermentableAdjunct.Potential, ColdSteep.COLDSTEEP_EFFICIENCY); Volumes.ColdSteepVolume += ColdSteep.GetColdSteepWaterContibution(grain.AmountGrams); } if (grain.Stage == FermentableStage.Mash) { grain.AmountGrams = GravityAlgorithms.GetGrainWeight(grain.GU, grain.FermentableAdjunct.Potential, gfc.MashEfficiency); grain.AmountGrams += (int)Math.Round(grain.AmountGrams * preBoilTappOffLoss); } if (grain.Stage == FermentableStage.Fermentor) { grain.AmountGrams = GravityAlgorithms.GetGrainWeight(grain.GU, grain.FermentableAdjunct.Potential, 1); var boilerLossPercent = GrainfatherCalculator.GRAINFATHER_BOILER_TO_FERMENTOR_LOSS / (Volumes.PostBoilVolume); grain.AmountGrams -= (int)Math.Round(boilerLossPercent * grain.AmountGrams); } if (grain.Stage == FermentableStage.Boil) { grain.AmountGrams = GravityAlgorithms.GetGrainWeight(grain.GU, grain.FermentableAdjunct.Potential, 1); } l.Add(grain); } GrainBillSize = Grist.Where(x => x.Stage == FermentableStage.Mash).Sum(x => x.AmountGrams); foreach (var grain in l) { Grist.Remove(grain); Grist.Add(grain); } if (GrainBillSize > GrainfatherCalculator.SMALL_GRAINBILL || GrainBillSize == 0) { TopUpMashWaterVolumeTextBox.Visibility = Visibility.Hidden; TopUpMashWaterVolumeLabel.Visibility = Visibility.Hidden; } else { TopUpMashWaterVolumeTextBox.Visibility = Visibility.Visible; TopUpMashWaterVolumeLabel.Visibility = Visibility.Visible; } foreach (GridViewColumn c in MaltsGridView.Columns) { c.Width = 0; //set it to no width c.Width = double.NaN; //resize it automatically } double ecb = ColorAlgorithms.CalculateColor(Grist.ToList(), Volumes); string refString = ColorAlgorithms.GetReferenceBeer(ecb); ColorLabel.Content = String.Format("Color [ECB]: {0:F1} eqv. to {1}", ecb, refString); recalculateIbu(); var ol = BoilHops.OrderBy(x => x).ToList(); BoilHops.Clear(); foreach (HopAddition h in ol) { hopsCompositionChanged(h); } } updateGuiText(); }