Пример #1
0
        private void refreshMaltGrid()
        {
            maltGrid.Rows.Clear();
            maltGrid.Columns.Clear();
            APIHandler          data     = new APIHandler();
            List <fermentable2> maltList = data.getFermentables();

            DataGridViewCell          cell        = new DataGridViewTextBoxCell();
            DataGridViewTextBoxColumn colMaltName = new DataGridViewTextBoxColumn()
            {
                CellTemplate     = cell,
                Name             = "name",
                HeaderText       = "Name",
                DataPropertyName = "name"
            };
            DataGridViewTextBoxColumn colMaltPPG = new DataGridViewTextBoxColumn()
            {
                CellTemplate     = cell,
                Name             = "ppg",
                HeaderText       = "PPG",
                DataPropertyName = "ppg",
                Width            = 50
            };
            DataGridViewTextBoxColumn colMaltColor = new DataGridViewTextBoxColumn()
            {
                CellTemplate     = cell,
                Name             = "color",
                HeaderText       = "Color",
                DataPropertyName = "color"
            };
            DataGridViewTextBoxColumn colMaltType = new DataGridViewTextBoxColumn()
            {
                CellTemplate     = cell,
                Name             = "type",
                HeaderText       = "Type",
                DataPropertyName = "type"
            };
            DataGridViewTextBoxColumn colMaltMaltster = new DataGridViewTextBoxColumn()
            {
                CellTemplate     = cell,
                Name             = "maltster",
                HeaderText       = "Maltster",
                DataPropertyName = "maltster"
            };
            DataGridViewTextBoxColumn colMaltID = new DataGridViewTextBoxColumn()
            {
                CellTemplate     = cell,
                Name             = "id",
                HeaderText       = "ID",
                DataPropertyName = "id",
                Visible          = false
            };

            maltGrid.Columns.Add(colMaltName);
            maltGrid.Columns.Add(colMaltPPG);
            maltGrid.Columns.Add(colMaltColor);
            maltGrid.Columns.Add(colMaltType);
            maltGrid.Columns.Add(colMaltMaltster);
            maltGrid.Columns.Add(colMaltID);
            var bindingList = new BindingList <fermentable2>(maltList);

            maltGrid.DataSource = bindingList;
        }
Пример #2
0
        /*
         * Sets all the f*****g shit for the grids and shit.
         * */
        public Recipe_Creator()
        {
            APIHandler handler = new APIHandler();

            //List<fermentable2> fermentableList = handler.getFermentables();
            //DataGridViewComboBoxColumn maltColumn = new DataGridViewComboBoxColumn();
            //maltColumn.DataSource = fermentableList;
            //maltColumn.DisplayMember = "name";
            // maltColumn.ValueMember = "id";
            //currentRecipe = currentRecipeFromMainScreen;
            //Malt Grid Stuff
            InitializeComponent();
            //MaltGrid.Columns.Add(maltColumn);
            MaltGrid.Columns.Add("Name", "Name");
            MaltGrid.Columns[0].ReadOnly = true;
            MaltGrid.Columns.Add("Weight", "Weight");
            MaltGrid.Columns.Add("PPG", "PPG");
            MaltGrid.Columns[2].ReadOnly = true;
            MaltGrid.Columns.Add("Color", "Color");
            MaltGrid.Columns[3].ReadOnly = true;
            DataGridViewCheckBoxColumn ExtractColumn = new DataGridViewCheckBoxColumn();

            ExtractColumn.ReadOnly   = true;
            ExtractColumn.Name       = "Extract";
            ExtractColumn.HeaderText = "Extract";
            MaltGrid.Columns.Add(ExtractColumn);
            MaltGrid.Columns[0].Width   = 150;
            MaltGrid.Columns[1].Width   = 50;
            MaltGrid.Columns[2].Width   = 50;
            MaltGrid.Columns[3].Width   = 50;
            MaltGrid.Columns[4].Width   = 50;
            KitEfficiencyBox.Text       = "" + KitEfficiency;
            IntoFermenterVolumeBox.Text = "" + IntoFermenterVolume;

            //Hop Grid Stuff
            HopGrid.Columns.Add("Name", "Name");
            HopGrid.Columns[0].ReadOnly = true;
            DataGridViewComboBoxColumn typeColumn = new DataGridViewComboBoxColumn();

            typeColumn.Name = "Type";
            typeColumn.Items.Add("Boil");
            typeColumn.Items.Add("Dry Hop");
            typeColumn.Items.Add("Whirlpool");
            typeColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
            HopGrid.Columns.Add(typeColumn);
            //HopGrid.Columns.Add("Type", "Type");
            HopGrid.Columns.Add("Amount", "Amount");
            HopGrid.Columns.Add("AAU", "AAU");
            HopGrid.Columns[3].ReadOnly = true;
            HopGrid.Columns.Add("Time", "Time");
            HopGrid.Columns[0].Width = 150;
            HopGrid.Columns[1].Width = 100;
            HopGrid.Columns[2].Width = 50;
            HopGrid.Columns[3].Width = 50;
            HopGrid.Columns[4].Width = 50;

            //Yeast Grid Stuff
            YeastGrid.Columns.Add("Lab", "Lab");
            YeastGrid.Columns[0].ReadOnly = true;
            YeastGrid.Columns.Add("Product", "Product");
            YeastGrid.Columns[1].ReadOnly = true;
            YeastGrid.Columns.Add("Attenuation", "Attenuation");
            YeastGrid.Columns[2].ReadOnly = true;
            YeastGrid.Columns[0].Width    = 100;
            YeastGrid.Columns[1].Width    = 100;
            YeastGrid.Columns[2].Width    = 100;
            RefreshStatistics();

            //Other Ingredients Grid Stuff
            OtherIngredientsGrid.Columns.Add("Name", "Name");
            OtherIngredientsGrid.Columns.Add("Amount", "Amount");
            OtherIngredientsGrid.Columns.Add("Unit", "Unit");
            OtherIngredientsGrid.Columns.Add("Time", "Time");
            OtherIngredientsGrid.Columns.Add("TimeUnit", "TimeUnit");
            OtherIngredientsGrid.Columns.Add("Type", "Type");


            RegistryKey adsfa = Registry.CurrentUser.OpenSubKey("SOFTWARE/Brewmeister");

            if (adsfa != null)
            {
                if (adsfa.GetValue("DataProvider").ToString() == "True")
                {
                    dataurl = "" + adsfa.GetValue("BeerNetAddress");
                }
                else
                {
                    dataurl = "" + adsfa.GetValue("DeploydAddress");
                }
                string currentRecipeKey = "" + adsfa.GetValue("LastOpenedRecipe");
                try
                {
                    //LastOpenedFileLocation = "" + adsfa.GetValue("LastOpenedFileLocation");
                    //openFile(LastOpenedFileLocation);
                    adsfa.Close();
                    currentRecipe = handler.loadRecipe(currentRecipeKey);
                    populateGrids();
                    RefreshStatistics();
                }
                catch (Exception esdjjs)
                {
                }
            }
            else
            {
                API_URL_Settings settings = new API_URL_Settings();
                settings.ShowDialog();
                dataurl = settings.restAPIURL;
                adsfa   = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("SOFTWARE/Brewmeister");
                adsfa.SetValue("dataurl", dataurl);
                adsfa.SetValue("LastOpenedRecipe", "");
                adsfa.Close();
            }

            //  populateGrids();
            //  RefreshStatistics();
            //  updateStyleSliders();
        }
Пример #3
0
        private void loadRecipe()
        {
            //load recipe
            //http://rest.unacceptable.beer:2403/recipe?id=decef696bf3f7806&include=fullrecipe

            string     jsonurl = dataurl + "/recipe?id=" + currentRecipeKey + "&include=fullrecipe";
            string     json    = new WebClient().DownloadString(jsonurl);
            APIHandler handler = new APIHandler();

            currentRecipe = handler.loadRecipe(currentRecipeKey);
            //currentRecipe = JsonConvert.DeserializeObject<recipe2>(json);
            int i = 1;

            //currentRecipe.name = rootObject.name;

            //var objects = JArray.Parse(json);
            //int i = 0;
            //foreach (JObject root in objects)
            //{
            //    foreach (KeyValuePair<String, JToken> recipeFromJson in root)
            //    {
            //        switch (recipeFromJson.Key)
            //        {
            //            case "name":
            //                currentRecipe.name = (String)recipeFromJson.Value;
            //                break;
            //            case "style":
            //                currentRecipe.style = (String)recipeFromJson.Value;
            //                break;
            //            case "description":
            //                currentRecipe.description = (String)recipeFromJson.Value;
            //                break;
            //            case "abv":
            //                currentRecipe.abv = (float)recipeFromJson.Value;
            //                break;
            //            case "ibu":
            //                currentRecipe.ibu = (float)recipeFromJson.Value;
            //                break;
            //            case "fg":
            //                currentRecipe.fg = (float)recipeFromJson.Value;
            //                break;
            //            case "og":
            //                currentRecipe.og = (float)recipeFromJson.Value;
            //                break;
            //            case "srm":
            //                currentRecipe.srm = (float)recipeFromJson.Value;
            //                break;
            //            case "version":
            //                currentRecipe.version = (float)recipeFromJson.Value;
            //                break;
            //            case "parentRecipe":
            //                currentRecipe.parentRecipe = (String)recipeFromJson.Value;
            //                break;
            //            case "clonedFrom":
            //                currentRecipe.clonedFrom = (String)recipeFromJson.Value;
            //                break;
            //            case "hidden":
            //                currentRecipe.hidden = (String)recipeFromJson.Value;
            //                break;
            //            case "id":
            //                currentRecipe.key = (String)recipeFromJson.Value;
            //                break;
            //        }
            //    }
            //}

            //load fermentables
            //jsonurl = dataurl + "/fermentableaddition?recipeid=" + currentRecipeKey;
            //if there's only one hop this might break
            //json = new WebClient().DownloadString(jsonurl);
            //objects = JArray.Parse(json);
            //i = 0;
            //foreach (JObject root in objects)
            //{
            //    foreach (KeyValuePair<String, JToken> recipeFromJson in root)
            //    {
            //        switch (recipeFromJson.Key)
            //        {
            //            case "name":
            //                currentRecipe.name = (String)recipeFromJson.Value;
            //                break;
            //        }
            //    }
            //}
            //load hops

            //load yeasts

            //load adjuncts
            RegistryKey adsfa = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE/Brewmeister", RegistryKeyPermissionCheck.ReadWriteSubTree);

            adsfa.SetValue("LastOpenedRecipe", currentRecipeKey);
        }
Пример #4
0
        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;
            }
        }