示例#1
0
        public static void AdaugareCuvant(TextBox textBoxCuvant, TextBox textBoxExplcatie, ComboBox comboBoxCategorie, Image imgPhoto, TextBox textBoxNewCategory)
        {
            CuvantDictionar cuv = new CuvantDictionar
            {
                Cuvant    = textBoxCuvant.Text,
                Descriere = textBoxExplcatie.Text,
                Categorie = comboBoxCategorie.Text,
                Imagine   = System.IO.Path.GetFileName(imgPhoto.Source.ToString())
            };

            if (cuv.Categorie == "")
            {
                cuv.Categorie = textBoxNewCategory.Text;
            }


            if (cuv.Cuvant == "" || cuv.Descriere == "" || cuv.Categorie == "")
            {
                MessageBox.Show("Cuvantul nu a fost adaugat\nInput invalid");
            }
            else
            {
                CuvinteDictionar.Add(cuv);
            }
        }
示例#2
0
        public static void InitiareJoc(Image image, TextBlock textBlock, Button button)
        {
            Random random = new Random();

            listaCuvinte = ListaCuvinteRandom();


            int elemRandom = random.Next(0, listaCuvinte.Count());

            points = 0;
            index  = 0;

            CuvantDictionar cuvAux = listaCuvinte.ElementAt(index);


            int comp = random.Next(0, 2);

            image.Source   = new BitmapImage(new Uri(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\Images\", cuvAux.Imagine)));
            textBlock.Text = cuvAux.Descriere;

            if (comp == 0 && cuvAux.Imagine != "no_image_available.jpg")
            {
                textBlock.Visibility = Visibility.Hidden;
            }
            else
            {
                image.Visibility = Visibility.Hidden;
            }
        }
示例#3
0
        public static void UrmatorulCuvant(Image image, TextBox raspuns, TextBlock textBlock, Button button)
        {
            if (listaCuvinte.ElementAt(index).Cuvant.Equals(raspuns.Text))
            {
                points++;
                MessageBox.Show("Corect");
            }
            else
            {
                MessageBox.Show("Incorect\nRaspuns corect:" + listaCuvinte.ElementAt(index).Cuvant);
            }
            index++;

            raspuns.Text = "";

            if (index < 5)
            {
                CuvantDictionar cuvAux = listaCuvinte.ElementAt(index);

                Random random = new Random();
                int    comp   = random.Next(0, 2);

                image.Source   = new BitmapImage(new Uri(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\Images\", cuvAux.Imagine)));
                textBlock.Text = cuvAux.Descriere;

                if (comp == 0 && cuvAux.Imagine != "no_image_available.jpg")
                {
                    textBlock.Visibility = Visibility.Hidden;
                    image.Visibility     = Visibility.Visible;
                }
                else
                {
                    textBlock.Visibility = Visibility.Visible;
                    image.Visibility     = Visibility.Hidden;
                }
            }

            if (index == 4)
            {
                button.Content = "Finish";
            }

            if (index == 5)
            {
                MessageBox.Show("Raspunsuri corecte:" + points + "/5");
                InitiareJoc(image, textBlock, button);
            }
        }