Ejemplo n.º 1
0
        public TCW(string aBSExportFilename, FermentableRepository aMaltRepo, HopsRepository aHopsRepo)
        {
            InitializeComponent();
            this.MaltsRepo = aMaltRepo;
            this.HopsRepo = aHopsRepo;

            FermentablesObservableList = new ObservableCollection<FermentableAdjunct>(aMaltRepo.Get());
            HopsObservableList = new ObservableCollection<Hops>(aHopsRepo.Get());

            BeersmithImporter = new BSImporter(aBSExportFilename);
            RecipeNameCombobox.ItemsSource = BeersmithImporter.GetAllRecipes();
            RecipeNameCombobox.SelectedIndex = 0;

            HopsListView.ItemsSource = HopsObservableList;
            MaltsListView.ItemsSource = FermentablesObservableList;

            WorkRecepie = new Recepie();

        }
Ejemplo n.º 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");
        }
Ejemplo n.º 3
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;
            Volumes.PreBoilTapOff = aRecepie.PreBoilTapOffVolume;
            TopUpMashWater = aRecepie.TopUpMashWater;

            OriginalGravity = aRecepie.OriginalGravity;

            BoilTime = aRecepie.BoilTime;

            NameTextBox.Text = aRecepie.Name;

            recalculateGrainBill();

            recalculateIbu();

            updateGuiTextboxes();
        }
Ejemplo n.º 4
0
        private void MenuItem_FileSave(object sender, RoutedEventArgs e)
        {
            var r = new Recepie();
            r.Fermentables = Grist.ToList();
            r.BoilHops = BoilHops.ToList();
            r.MashProfile = MashProfileList.ToList();
            r.OtherIngredients = OtherIngredientsList.ToList();
            r.Name = NameTextBox.Text;

            r.BatchVolume = Volumes.FinalBatchVolume;
            r.PreBoilTapOffVolume = Volumes.PreBoilTapOff;
            r.TopUpMashWater = 0;

            r.OriginalGravity = OriginalGravity;
            r.BoilTime = BoilTime;


            // Create OpenFileDialog 
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();



            // Set filter for file extension and default file extension 
            dlg.DefaultExt = ".gsrx";
            dlg.Filter = "Grainfather recipe files (*.gsrx)|*.gsrx";
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dlg.FileName = NameTextBox.Text;

            // Display OpenFileDialog by calling ShowDialog method 
            Nullable<bool> result = dlg.ShowDialog();


            if (result != true)
                return;

            XmlSerializer serializer = new XmlSerializer(typeof(Recepie));
            FileStream saveStream = new FileStream(dlg.FileName, FileMode.OpenOrCreate, FileAccess.Write);
            serializer.Serialize(saveStream, r);
            saveStream.Close();



        }