Exemple #1
0
        private void saveRecipeButton_Click(object sender, EventArgs e)
        {
            dataManager.RecipesList.Recipes.Add(newRecipe);
            //dataManager.save();
            recipeBindingSource.ResetBindings(false);

            recipesNewStepIngredients.Text = "";
            recipesNewServingsVal.Text = "";
            recipesNewTimeVal.Text = "";
            recipesNewStepDescription.Text = "";
            recipesNewStepName.Text = "";

            MessageBox.Show("Recipe added!");

            recipesNewSteps.Value = 0;
            recipesNewSteps.Maximum = 0;
            newRecipe = new Recipe();
            newRecipe.Steps = new List<RecipeStep>();
            prev = 0;
            recipesNewStepsCount.Text = recipesNewSteps.Maximum + "";

            recipesNewServings.Show();
            recipesNewServingsVal.Show();
            recipesNewTime.Show();
            recipesNewTimeVal.Show();
            recipesNewStepIngredients.Hide();
            recipesNewStepIngridLabel.Hide();
        }
Exemple #2
0
        Recipe getRecipe(int id)
        {
            try
            {
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(config.Current.serverAddress + "/synchro/recipe/"+id);

                req.AllowWriteStreamBuffering = true;
                req.KeepAlive = true;
                req.Method = "Get";
                HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
                XmlTextReader xmltr = new XmlTextReader(HttpWResp.GetResponseStream());
                Recipe recipe = new Recipe();
                recipe.Deserialize(xmltr);
                HttpWResp.Close();

                for (int i = 0; i < recipe.Steps.Count; i++)
                    for (int j = 0; j < recipe.Steps[i].Ingredients.Count; j++)
                        recipe.Steps[i].Ingredients[j].Product = productsList.getById(recipe.Steps[i].Ingredients[j].ProductId);

                return recipe;
            }
            catch (WebException ee)
            {
                /*
                WebResponse resp = ee.Response;

                StreamReader sr=new StreamReader(resp.GetResponseStream());
                string allresp=sr.ReadToEnd();
                string respmes = ee.Message;

                 */
                MessageBox.Show(ee.Message);
                return null;
            }
        }
Exemple #3
0
        private void RecipesTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (RecipesTabControl.TabPages[RecipesTabControl.SelectedIndex].Equals(RecipeInfo))
            {
                if (recipesDataGrid.CurrentRowIndex < 0 || recipesDataGrid.CurrentRowIndex >= dataManager.RecipesList.Recipes.Count)
                {
                    RecipeInfo.Hide();
                }
                else
                {
                    Recipe recipe = dataManager.RecipesList.Recipes[recipesDataGrid.CurrentRowIndex];
                    recipesInfoNumSteps.Text = recipe.Steps.Count + "";
                    recipesInfoSteps.Maximum = recipe.Steps.Count;
                    recipesInfoSteps.Value = 0;

                    recipesInfoStepDescription.Text = recipe.Description;
                    recipesInfoStepName.Text = recipe.Name;
                    recipesInfoServVal.Text = recipe.NumberOfServings + "";
                    recipesInfoTimeVal.Text = recipe.MinutesToPrepare + "";

                    recipesInfoServ.Show();
                    recipesInfoServVal.Show();
                    recipesInfoTime.Show();
                    recipesInfoTimeVal.Show();
                    recipesInfoStepIngredients.Hide();
                    recipesInfoIngridLabel.Hide();

                    RecipeInfo.Show();
                }
            }
            else if (RecipesTabControl.TabPages[RecipesTabControl.SelectedIndex].Equals(recipesNew))
            {
                newRecipe = new Recipe();
                newRecipe.Steps = new List<RecipeStep>();

                recipesNewSteps.Value = 0;
                recipesNewSteps.Maximum = 0;
                prev = 0;
                recipesNewStepsCount.Text = recipesNewSteps.Maximum+"";

                recipesNewServings.Show();
                recipesNewServingsVal.Show();
                recipesNewTime.Show();
                recipesNewTimeVal.Show();
                recipesNewStepIngredients.Hide();
                recipesNewStepIngridLabel.Hide();
            }
        }
Exemple #4
0
        public void loadRecipes()
        {
            List<Recipe> rList = new List<Recipe>();
            foreach (RecipeForList r in recipesList.ListedRecipies)
            {
                Recipe re = new Recipe();
                XmlTextReader xmlr = new XmlTextReader(RecipeFile+r.id+".xml");
                re.Deserialize(xmlr);
                xmlr.Close();

             //   for (int i = 0; i < re.Steps.Count; i++)
               //     for (int j = 0; j < re.Steps[i].Ingredients.Count; j++)
                 //       re.Steps[i].Ingredients[j].Product = productsList.getById(re.Steps[i].Ingredients[j].ProductId);

                rList.Add(re);
            }
            recipesList.Recipes = rList;
        }