Exemple #1
0
        private void PopulateGUI(Recepie aRecepie)
        {
            Grist.Clear();
            foreach (GristPart g in aRecepie.Fermentables)
            {
                Grist.Add(g);
            }

            BoilHops.Clear();
            foreach (HopAddition h in aRecepie.BoilHops)
            {
                BoilHops.Add(h);
            }

            MashProfileList.Clear();
            foreach (Domain.MashProfileStep mps in aRecepie.MashProfile)
            {
                MashProfileList.Add(mps);
            }

            OtherIngredientsList.Clear();
            foreach (OtherIngredient o in aRecepie.OtherIngredients)
            {
                OtherIngredientsList.Add(o);
            }


            Volumes.FinalBatchVolume    = aRecepie.BatchVolume;
            BatchSizeVolumeTextBox.Text = Volumes.FinalBatchVolume.ToString();

            Volumes.PreBoilTapOff     = aRecepie.PreBoilTapOffVolume;
            PreBoilVolumeTextBox.Text = Volumes.PreBoilTapOff.ToString();

            TopUpMashWater = aRecepie.TopUpMashWater;
            TopUpMashWaterVolumeTextBox.Text = TopUpMashWater.ToString();

            OriginalGravity = aRecepie.OriginalGravity;
            ExpectedOriginalGravityTextBox.Text = OriginalGravity.ToString();

            BoilTime             = aRecepie.BoilTime;
            BoilTimeTextBox.Text = BoilTime.ToString();

            NameTextBox.Text = aRecepie.Name;


            recalculateGrainBill();

            recalculateIbu();

            updateGuiText();
        }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();

            var assembly = Assembly.GetExecutingAssembly();
            var path     = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var fullpath = String.Format("{0}\\{1}", path, assembly.GetName().Name);

            try {
                if (!Directory.Exists(fullpath))
                {
                    Directory.CreateDirectory(fullpath);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Unable to create {0}. Exception {1}", fullpath, e));
            }
            HopsRepo = new HopsRepository();
            MaltRepo = new FermentableRepository();

            Grist = new ObservableCollection <GristPart>();
            MaltsListView.ItemsSource = Grist;
            BoilHops = new ObservableCollection <HopAddition>();
            HopsListView.ItemsSource = BoilHops;

            MashProfileList = new ObservableCollection <Domain.MashProfileStep>();
            MashStepListView.ItemsSource = MashProfileList;

            OtherIngredientsList = new ObservableCollection <OtherIngredient>();
            OtherIngredientsListView.ItemsSource = OtherIngredientsList;

            OriginalGravity = 1.05;
            BoilTime        = 60;

            Volumes                       = new BrewVolumes();
            Volumes.BoilOffLoss           = GrainfatherCalculator.CalcBoilOffVolume(BoilTime);
            Volumes.FinalBatchVolume      = 25;
            Volumes.BoilerToFermentorLoss = GrainfatherCalculator.GRAINFATHER_BOILER_TO_FERMENTOR_LOSS;
            Volumes.PreBoilTapOff         = 0;

            TopUpMashWater = 0;

            gfc = new GrainfatherCalculator();
            gfc.MashEfficiency = (double)WpfApplication1.Properties.Settings.Default["MashEfficiency"];
            EstAtten           = 78;
            updateGuiText();

            GrainBrainMenuItem.IsEnabled = false;

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 5);
            dispatcherTimer.Start();

            MashProfileList.CollectionChanged += this.OnCollectionChanged;

            BatchSizeVolumeTextBox.Text         = Volumes.FinalBatchVolume.ToString();
            ExpectedOriginalGravityTextBox.Text = OriginalGravity.ToString();
            BoilTimeTextBox.Text             = BoilTime.ToString();
            TopUpMashWaterVolumeTextBox.Text = TopUpMashWater.ToString();
            PreBoilVolumeTextBox.Text        = Volumes.PreBoilTapOff.ToString();
        }