Пример #1
0
        private void handleSelectHops()
        {
            HopAddition h = new HopAddition();

            if (HopsListView.SelectedItem != null)
            {
                var bsh = BSBoilHops.First();

                h.Hop = (Hops)(HopsListView.SelectedItem);
                Debug.Assert(WorkRecepie.BatchVolume != 0);
                h.Amount   = (bsh.Amount) / (WorkRecepie.BatchVolume);
                h.Duration = bsh.BoilTime;


                WorkRecepie.BoilHops.Add(h);
                var del = BSBoilHops.First();
                BSBoilHops.Remove(del);


                if (BSGrainBill.Count == 0)
                {
                    ImportedRecepie = WorkRecepie;
                    this.Close();
                }
                else
                {
                    TextblockHops.Text = "Please select a corresponding hops for " + BSBoilHops.First().Name + " with alpha acid " + BSBoilHops.First().AlphaAcid.ToString();
                }
            }
            else
            {
                MessageBox.Show("Please select a hop in the list to match the imported one");
            }
        }
Пример #2
0
        private void handleSelectHops()
        {
            HopAddition h = new HopAddition();
            if (HopsListView.SelectedItem != null)
            {
                var bsh = BSBoilHops.First();

                h.Hop = (Hops)(HopsListView.SelectedItem);
                Debug.Assert(WorkRecepie.BatchVolume != 0);
                h.Amount = (bsh.Amount) / (WorkRecepie.BatchVolume);
                h.Duration = bsh.BoilTime;


                WorkRecepie.BoilHops.Add(h);
                var del = BSBoilHops.First();
                BSBoilHops.Remove(del);


                if (BSGrainBill.Count == 0)
                {
                    ImportedRecepie = WorkRecepie;
                    this.Close();
                }
                else
                    TextblockHops.Text = "Please select a corresponding hops for " + BSBoilHops.First().Name + " with alpha acid " + BSBoilHops.First().AlphaAcid.ToString();

            }
            else
                MessageBox.Show("Please select a hop in the list to match the imported one");
        }
Пример #3
0
        public SelectHops(HopsRepository aRepo, HopAddition aHopAddition)
        {
            InitializeComponent();

            var hopsRepo = aRepo;
            var hops = hopsRepo.Get();
            HopsComboBox.ItemsSource = hops;

            HopsComboBox.SelectedValue = hops.FirstOrDefault(x => x.Name.Equals(aHopAddition.Hop.Name));

            TimeDurationTextBox.Text = aHopAddition.Duration.ToString();
            StageComboBox.ItemsSource = Enum.GetValues(typeof(HopAdditionStage)).Cast<HopAdditionStage>();
            StageComboBox.SelectedItem = (HopAdditionStage)aHopAddition.Stage;

            if (aHopAddition.AmountUnit == HopAmountUnitE.IBU)
            {
                UnitCheckBox.IsChecked = false;
                AmountLabel.Content = "Bitterness [IBU] :";
                AmountTextBox.Text = aHopAddition.Bitterness.ToString();
            }
            else
            {
                UnitCheckBox.IsChecked = true;
                AmountLabel.Content = "Amount [g/L] :";
                AmountTextBox.Text = aHopAddition.Amount.ToString();
            }
        }
Пример #4
0
        private void HopsListView_KeyDown(object sender, KeyEventArgs e)
        {
            if (HopsListView.SelectedIndex >= BoilHops.Count() || HopsListView.SelectedIndex < 0)
            {
                return;
            }

            if (Key.Delete == e.Key)
            {
                HopAddition h = (HopAddition)HopsListView.SelectedItem;
                BoilHops.Remove(h);
                recalculateIbu();
            }
        }
Пример #5
0
        private void hopsCompositionChanged(HopAddition addedHop)
        {
            if (addedHop != null)
            {
                var vol = Volumes.FinalBatchVolume;
                if (addedHop.Stage == HopAdditionStage.Boil)
                {
                    vol = Volumes.PostBoilVolume;
                }

                addedHop.AmountGrams = addedHop.Amount * vol;
                BoilHops.Add(addedHop);
            }
            recalculateIbu();
        }
Пример #6
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Hops var = (Hops)HopsComboBox.SelectedItem;
            hop = new HopAddition();

            if (var == null)
            {
                MessageBox.Show("Please select a hop in the drop down menu");
                return;
            }
            hop.Hop = var;

            var stage = (HopAdditionStage)StageComboBox.SelectedItem;
            hop.Stage = stage;

            int timeMinutes;
            if (int.TryParse(TimeDurationTextBox.Text, out timeMinutes))
            {
                hop.Duration = timeMinutes;
            }
            else
                MessageBox.Show(String.Format("Unable to interpreter {0} as a integer value. Please provide a correct integer value in Time", TimeDurationTextBox.Text));


            float amount;
            if (float.TryParse(AmountTextBox.Text, out amount))
            {
                if (UnitCheckBox.IsChecked == false)
                {
                    hop.Bitterness = (int)Math.Round(amount,0);
                    hop.AmountUnit = HopAmountUnitE.IBU;
                }
                else
                {
                    hop.Amount = Math.Round(amount, 2);
                    hop.AmountUnit = HopAmountUnitE.GRAMS_PER_LITER;
                }
                    
                this.Close();
            }
            else
                MessageBox.Show(String.Format("Unable to interpreter {0} as a float value. Please provide a correct float value in Part", AmountTextBox.Text));


        }
Пример #7
0
        public SelectHops(HopsRepository aRepo, HopAddition aHopAddition)
        {
            InitializeComponent();

            var hopsRepo = aRepo;
            var hops     = hopsRepo.Get();

            HopsComboBox.ItemsSource = hops;

            HopsComboBox.SelectedValue = hops.FirstOrDefault(x => x.Name.Equals(aHopAddition.Hop.Name));

            TimeDurationTextBox.Text   = aHopAddition.Duration.ToString();
            StageComboBox.ItemsSource  = Enum.GetValues(typeof(HopAdditionStage)).Cast <HopAdditionStage>();
            StageComboBox.SelectedItem = (HopAdditionStage)aHopAddition.Stage;

            if (aHopAddition.AmountUnit == HopAmountUnitE.IBU)
            {
                UnitCheckBox.IsChecked = false;
                AmountLabel.Content    = "Bitterness [IBU] :";
                AmountTextBox.Text     = aHopAddition.Bitterness.ToString();
            }
            else
            {
                UnitCheckBox.IsChecked = true;
                AmountLabel.Content    = "Amount [g/L] :";
                AmountTextBox.Text     = aHopAddition.Amount.ToString();
            }
            if (aHopAddition.AlphaAcid != null)
            {
                AlphaAcidTextBox.Text = aHopAddition.AlphaAcid.GetAphaAcid().ToString();
            }
            else
            {
                AlphaAcidTextBox.Text = "-";
            }
        }
Пример #8
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Hops var = (Hops)HopsComboBox.SelectedItem;

            hop = new HopAddition();

            if (var == null)
            {
                MessageBox.Show("Please select a hop in the drop down menu");
                return;
            }
            hop.Hop = var;

            var stage = (HopAdditionStage)StageComboBox.SelectedItem;

            hop.Stage = stage;

            int timeMinutes;

            if (int.TryParse(TimeDurationTextBox.Text, out timeMinutes))
            {
                hop.Duration = timeMinutes;
            }
            else
            {
                MessageBox.Show(String.Format("Unable to interpreter {0} as a integer value. Please provide a correct integer value in Time", TimeDurationTextBox.Text));
            }


            float amount;

            if (float.TryParse(AmountTextBox.Text, out amount))
            {
                if (UnitCheckBox.IsChecked == false)
                {
                    hop.Bitterness = (int)Math.Round(amount, 0);
                    hop.AmountUnit = HopAmountUnitE.IBU;
                }
                else
                {
                    hop.Amount     = Math.Round(amount, 2);
                    hop.AmountUnit = HopAmountUnitE.GRAMS_PER_LITER;
                }
            }
            else
            {
                MessageBox.Show(String.Format("Unable to interpreter {0} as a float value. Please provide a correct float value in Part", AmountTextBox.Text));
            }


            float alphaAcid;

            if (float.TryParse(AlphaAcidTextBox.Text, out alphaAcid))
            {
                HopAcids acid = new HopAcids();
                acid.Min      = alphaAcid;
                hop.AlphaAcid = acid;
            }
            else
            {
                MessageBox.Show(String.Format("Unable to interpreter {0} as a float value. Please provide a correct float value in Part", AlphaAcidTextBox.Text));
            }

            this.Close();
        }
Пример #9
0
        private void hopsCompositionChanged(HopAddition addedHop)
        {
            if (addedHop != null)
            {
                var vol = Volumes.FinalBatchVolume;
                if (addedHop.Stage == HopAdditionStage.Boil)
                    vol = Volumes.PostBoilVolume;

                addedHop.AmountGrams = addedHop.Amount * vol;
                BoilHops.Add(addedHop);
            }
            recalculateIbu();
        }