Example #1
0
 /// <summary>
 /// Create a pdf file of a single recipe
 /// </summary>
 /// <param name="recipe">Recipe Entry</param>
 /// <param name="filename">string of save location</param>
 /// <param name="preview">bool</param>
 public static void SingleRecipePDF(RecipeEntry recipe, string filename, bool preview)
 {
     Document file = new Document();
     file.Info.Title = recipe.Name;
     Section section = file.AddSection();
     DrawRecipe(recipe, ref section);
     SavePDF(file, filename, preview);
 }
Example #2
0
 /// <summary>
 /// Checks if the current recipe has been saved based on the values of the text fields.
 /// </summary>
 /// <returns>new bool</returns>
 public bool HasSaved()
 {
     bool hasSaved = true;
     foreach (TextBox c in grd_RecipeEntry.Children.OfType<TextBox>())
     {
         if (c.Text.Length > 0)
             hasSaved = false;
     }
     RecipeEntry recTemp = new RecipeEntry(txt_RecipeName.Text, txt_RecipeSource.Text, (RecipeCategory)cmb_RecipeCategory.SelectedItem, txt_RecipeDescription.Text, txt_RecipePrepInstructions.Text, txt_RecipeCookInstructions.Text, _Ingredients, SelectedRecipe);
     if (_Recipes.Contains(recTemp))
     {
         hasSaved = true;
     }
     return hasSaved;
 }
Example #3
0
 private static void DrawRecipe(RecipeEntry recipe, ref Section section)
 {
     ///<example>
     ///     [Recipe Name]
     ///     [Recipe Source]
     ///  [Recipe Description]
     ///  [# Recipe Ingredients]
     ///  [Recipe Preparation Instructions]
     ///  [Recipe Cooking Instructions]
     /// </example>
     Paragraph headerText = section.AddParagraph();
     Paragraph DescParagraph = section.AddParagraph();
     Paragraph ingredientList = section.AddParagraph();
     Paragraph PrepInstr = section.AddParagraph();
     Paragraph CookInstr = section.AddParagraph();
     Font header = new Font("Times New Roman Bold", 20);
     Font body = new Font("Times New Roman", 14);
     headerText.Format = HeaderFormatter();
     headerText.AddFormattedText(recipe.Name, header);
     headerText.AddLineBreak();
     headerText.AddFormattedText("(" + recipe.Source + ")", new Font("Times New Roman", 16));
     DescParagraph.Format = BodyFormatter();
     DescParagraph.AddFormattedText(recipe.Description, body);
     ingredientList.Format = IngredientFormatter();
     int count = 1;
     foreach (IngredientEntry i in recipe.Ingredients)
     {
         string entry = count.ToString() + ") " + i.ToString();
         ingredientList.AddFormattedText(entry, body);
         ingredientList.AddLineBreak();
         count++;
     }
     PrepInstr.Format = BodyFormatter();
     PrepInstr.AddFormattedText(recipe.PrepInstructions, body);
     CookInstr.Format = BodyFormatter();
     CookInstr.AddFormattedText(recipe.CookInstructions, body);
 }
Example #4
0
 public void SaveRecipe()
 {
     int id;
     if (SelectedRecipe == -1)
     {
         try
         {
             Recipes.InsertRecipe(txt_RecipeName.Text, txt_RecipeSource.Text, (RecipeCategory)cmb_RecipeCategory.SelectedItem, txt_RecipeDescription.Text, txt_RecipePrepInstructions.Text, txt_RecipeCookInstructions.Text, _Ingredients, out id);
         }
         catch (Exception e)
         {
             id = -1;
             MessageBox.Show(e.Message);
         }
         RecipeEntry _rec = new RecipeEntry(txt_RecipeName.Text, txt_RecipeSource.Text, (RecipeCategory)cmb_RecipeCategory.SelectedItem, txt_RecipeDescription.Text, txt_RecipePrepInstructions.Text, txt_RecipeCookInstructions.Text, _Ingredients, id);
         _Recipes.Add(_rec);
     }
     else
     {
         id = SelectedRecipe;
         try
         {
             Recipes.UpdateRecipe(txt_RecipeName.Text, txt_RecipeSource.Text, (RecipeCategory)cmb_RecipeCategory.SelectedItem, txt_RecipeDescription.Text, txt_RecipePrepInstructions.Text, txt_RecipeCookInstructions.Text, _Ingredients, id);
         }
         catch(Exception e)
         {
             id = -1;
             MessageBox.Show(e.Message);
         }
         _Recipes.Where(r => r.recID == SelectedRecipe).First().UpdateRecipe(txt_RecipeName.Text, txt_RecipeSource.Text, txt_RecipeDescription.Text, txt_RecipePrepInstructions.Text, txt_RecipeCookInstructions.Text, _Ingredients);
     }
     RefreshRecipeList();
 }
Example #5
0
 private void BuildRecipeListBox()
 {
     try
     {
         using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext())
         {
             var r = from re in db.Recipes select re;
             foreach(Recipe re in r)
             {
                 var i = from ing in db.Ingredients join ri in db.RecipeIngredients on ing.ing_ID equals ri.ing_ID where ri.rec_ID == re.rec_ID select ing;
                 List<IngredientEntry> ingredients = new List<IngredientEntry>();
                 foreach(Ingredient ing in i)
                 {
                     var m = from mes in db.RecipeIngredients where mes.ing_ID == ing.ing_ID && mes.rec_ID == re.rec_ID select mes.Measurement;
                     var a = from mes in db.RecipeIngredients where mes.ing_ID == ing.ing_ID && mes.rec_ID == re.rec_ID select mes.ri_Amount;
                     IngredientEntry ingred = new IngredientEntry(ing, m.First(), (double)a.First());
                     ingredients.Add(ingred);
                 }
                 RecipeEntry rec = new RecipeEntry(re.rec_Name, re.rec_Source,(RecipeCategory)cmb_RecipeCategory.SelectedItem,re.rec_Description,re.rec_PreparationInstructions,re.rec_CookingInstructions, ingredients, re.rec_ID);
                 _Recipes.Add(rec);
             }
         }
         lst_Recipes.ItemsSource = _Recipes;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }