Beispiel #1
0
        private void StartTest(int category)
        {
            RecipeManager recipesManager = new RecipeManager();
            List <Recipe> recipes        = recipesManager.GetList();
            List <int>    indexes        = new List <int>();

            for (int i = 0; i < recipes.Count; i++)
            {
                if (recipes[i].CategoryId != category || recipes[i].Level > Level)
                {
                    recipes.RemoveAt(i);
                    i--;
                }
                else
                {
                    indexes.Add(i);
                }
            }
            TestManager testManager = new TestManager(volume);
            bool        GameEnd     = testManager.StartGame(recipes, indexes, User);

            if (GameEnd)
            {
                gform.ReturnToMenu();
                closeAfterGame = true;
                this.Close();
            }
        }
Beispiel #2
0
        private void buttonRandom_Click(object sender, EventArgs e)
        {
            if (volume)
            {
                MusicManager.playSound();
            }
            RecipeManager recipesManager = new RecipeManager();
            List <Recipe> recipes        = recipesManager.GetList();
            List <int>    indexes        = new List <int>();

            for (int i = 0; i < recipes.Count; i++)
            {
                if (recipes[i].Level > Level)
                {
                    recipes.RemoveAt(i);
                    i--;
                }
                else
                {
                    indexes.Add(i);
                }
            }
            TestManager testManager = new TestManager(volume);

            if (testManager.StartGame(recipes, indexes, User))
            {
                ReturnToMenu();
            }
        }
        private void RecipeBookForm_Load(object sender, EventArgs e)
        {
            this.AllowTransparency     = true;
            this.BackColor             = Color.DarkGoldenrod;
            this.TransparencyKey       = this.BackColor;
            rtbIngredients.ScrollBars  = RichTextBoxScrollBars.None;
            rtbRecipe.ScrollBars       = RichTextBoxScrollBars.None;
            rtbIngredients.MouseWheel += new MouseEventHandler(rtbIngredients_MouseWheel);
            rtbRecipe.MouseWheel      += new MouseEventHandler(rtbRecipe_MouseWheel);
            try
            {
                RecipeManager recipesManager = new RecipeManager();
                recipes = recipesManager.GetList();
                for (int i = 0; i < recipes.Count; i++)
                {
                    if (recipes[i].CategoryId != Category || recipes[i].Level > Level)
                    {
                        recipes.RemoveAt(i);
                        i--;
                    }
                }
                if (recipes.Count != 0)
                {
                    pbImage.BackgroundImage       = recipes[0].Image;
                    pbImage.BackgroundImageLayout = ImageLayout.Stretch;
                    labelName.Text      = recipes[0].Name;
                    rtbIngredients.Text = "";
                    for (int i = 0; i < recipes[0].Ingredients.Count; i++)
                    {
                        rtbIngredients.Text += recipes[0].Ingredients[i] + "\n";
                    }
                    rtbRecipe.Text = recipes[0].Description.Replace("#", "");
                    pbBack.Visible = false;
                    if (recipes.Count == 1)
                    {
                        pbForward.Visible = false;
                    }

                    if (rtbRecipe.Text.Length > 450)
                    {
                        pbDown2.Visible = true;
                    }
                    else
                    {
                        pbDown2.Visible = false;
                    }
                    if (rtbIngredients.Lines.Length > 6)
                    {
                        pbDown.Visible = true;
                    }
                    else
                    {
                        pbDown.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }