Esempio n. 1
0
        public static void SetUpRecipe(string path, string jsonName, int ID, DateTime recipeDate, string RTFFileName)
        {
            string name        = "";
            string caloriesNo  = "";
            string description = "";
            string ingredients = "";
            string grams       = "";
            string proteins    = "";
            string carbons     = "";
            string fats        = "";
            var    jsonContent = MyMethodsLib.LoadJson(path, jsonName);

            foreach (MyMethodsLib.Item item in jsonContent)
            {
                if (item.ID == ID)
                {
                    name        = item.Name;
                    caloriesNo  = item.CaloriesNo.ToString();
                    description = item.Description;
                    ingredients = item.Ingredients;
                    grams       = item.Gram.ToString();
                    proteins    = item.Proteins.ToString();
                    carbons     = item.Carbons.ToString();
                    fats        = item.Fats.ToString();
                    break;
                }
            }
            FileInfo     rtf    = new FileInfo(RTFFileName);
            DocumentCore rtfdoc = new DocumentCore();

            rtfdoc.Content.Start.Insert(String.Format("RECIPE FOR DAY: \t \t"),
                                        new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.DarkMagenta, Bold = true, Size = 16
            });
            rtfdoc.Content.End.Insert(String.Format(recipeDate.ToString("dddd, dd MMMM yyyy")), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.DarkMagenta, Italic = true, Bold = true, Size = 14
            });
            rtfdoc.Content.End.Insert(String.Format("\n"));
            rtfdoc.Content.End.Insert(String.Format("Calories: \t"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Red, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(caloriesNo), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(" kcal"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format("\tGram: \t"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Red, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(grams), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(" g"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format("\tProtein: \t"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Red, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(proteins), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(" g"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format("\tCarbon: \t"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Red, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(carbons), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(" g"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format("\t Fat: \t"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Red, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(fats), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format(" g"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 9
            });
            rtfdoc.Content.End.Insert(String.Format("\n"));
            rtfdoc.Content.End.Insert(String.Format(name), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Italic = true, Size = 14, AllCaps = true
            });
            rtfdoc.Content.End.Insert(String.Format("\n\nIngredients: \n"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 13
            });
            rtfdoc.Content.End.Insert(String.Format(ingredients), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Italic = true, Size = 12
            });
            rtfdoc.Content.End.Insert(String.Format("\n\nDescription: \n"), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Bold = true, Size = 13
            });
            rtfdoc.Content.End.Insert(String.Format(description), new CharacterFormat()
            {
                FontName = "Garamont", FontColor = SautinSoft.Document.Color.Black, Italic = true, Size = 12
            });
            rtfdoc.Save(rtf.FullName, SaveOptions.RtfDefault);
            checkForTesting = true;
        }