Beispiel #1
0
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            currentLesson   = navigationParameter as Lesson;
            lessonHadLearnt = new HadLearnt(currentLesson);
            arrayColors[0]  = new SolidColorBrush(Colors.Blue);
            arrayColors[1]  = new SolidColorBrush(Colors.Red);
            arrayColors[2]  = new SolidColorBrush(Colors.Green);
            arrayColors[3]  = new SolidColorBrush(Colors.Turquoise);
            arrayColors[4]  = new SolidColorBrush(Colors.Yellow);
            Random r = new Random();

            for (int k = 0; k < lessonHadLearnt.lesson_learnt.Count; k++)
            {
                foreach (var item in lessonHadLearnt.lesson_learnt[k].lettersForLesson)
                {
                    tbBig.Add(new TextBlock()
                    {
                        Text = item.LettersBigShape, Foreground = new SolidColorBrush(Colors.Black), Height = 100, Width = 100, FontSize = 60, Tag = false
                    });
                    tbBig[i].Tapped += ex1_Tapped;

                    tbsmall.Add(new TextBlock()
                    {
                        Text = item.LettersSmallShape, Foreground = new SolidColorBrush(Colors.Black), Height = 100, Width = 100, FontSize = 60,
                    });
                    tbsmall[i].Tapped += ex1_Tapped;
                    i++;
                }
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        //protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        //{
        //    if (pageState != null && pageState.ContainsKey("game_pic_source"))
        //        game_pic.Source = pageState["game_pic_source"] as ImageSource;
        //    if (pageState != null && pageState.ContainsKey("mainGrid"))
        //        mainGrid = pageState["mainGrid"] as Grid;
        //    currentLesson = navigationParameter as Lesson;
        //    lessonHadLearnt = new HadLearnt(currentLesson);
        //    //int [,]matGrid=new int [3,4];

        //    int i = 0;
        //    foreach (var picture in lessonHadLearnt.pictuers_HadLearnt)
        //    {
        //        //r.Next(1, 4) r.Next(1, 3)

        //        //הוספת טב לליסט
        //        images.Add(picture.WordPictuer);
        //        tb.Add(new TextBlock() { Text = picture.LettersBigShape, FontSize = 50, Foreground = new SolidColorBrush(Colors.Maroon) });
        //        tb[i++].Tapped += game_discoverThePicture_Tapped;

        //        //הגרלה עד שמוגרל מקום פנוי


        //        //else
        //        //{


        //        //    //Grid.SetColumn(tb[i], k);
        //        //    //Grid.SetRow(tb[i], j);
        //        //    //matGrid[j, k] = 1;
        //        //    //game_grid.Children.Add(tb[i]);
        //        //    //i++;

        //        //}
        //        //}


        //        //Grid.SetColumn(tb[i],k );
        //        //Grid.SetRow(tb[i],j );


        //    }

        //    insertPictuer();
        //}
        //int y = 1;
        //int x = 1;
        //void game_discoverThePicture_Tapped(object sender, TappedRoutedEventArgs e)
        //{
        //    TextBlock tb;
        //    //int [,]arrTb =new int[6,2];
        //    tb = sender as TextBlock;


        //    if (tb.Text.Equals(lettersBigShape))
        //    {
        //        tb.Margin = new Thickness(20, 0, 0, 0);
        //        tb.Foreground = new SolidColorBrush(Colors.Yellow);

        //        //מחיקה
        //        game_grid.Children.Remove(tb);
        //        //TextBlock tb1 = game_grid.Children[0] as TextBlock;
        //        //העברה
        //        int f = 0;

        //        if (y < 6 && f == 0)
        //        {
        //            Grid.SetColumn(tb, 0);
        //            Grid.SetRow(tb, y++);
        //        }
        //        else
        //        {
        //            f = 1;
        //            Grid.SetColumn(tb, 1);
        //            Grid.SetRow(tb, x++);
        //        }
        //        mainGrid.Children.Add(tb);
        //        insertPictuer();

        //    }
        //}
        //int c = 0;
        //private async void insertPictuer()
        //{
        //    int i = 0;
        //    int[,] matGrid = new int[6, 6];
        //    int j, k;
        //    //מגריל מקום
        //    j = r.Next(1, 6);
        //    k = r.Next(1, 6);
        //    int y;


        //    //אם נשארו תמונות שלא השתמשו
        //    if (c++ < x)
        //    {
        //        //מגריל תמונה כל עוד לא ציון שהיא כבר הגיעה
        //        do
        //        {
        //            y = r.Next(0,images.Count());
        //            game_pic.Source = images[y];
        //            lettersBigShape = tb[y].Text;
        //        }
        //        while (lessonHadLearnt.pictuers_HadLearnt[y].WordPictuerUsed == true);
        //        for (int l = 0; matGrid[j, k] == 1 && l < 36; l++)
        //            {
        //                k = r.Next(1, 6);
        //                j = r.Next(1, 6);
        //            }
        //            if (matGrid[j, k] == 0)
        //            {
        //                Grid.SetColumn(tb[i], k);
        //                Grid.SetRow(tb[i], j);
        //                matGrid[j, k] = 1;
        //                game_grid.Children.Add(tb[i]);
        //                i++;

        //            }
        //        lessonHadLearnt.pictuers_HadLearnt[y].WordPictuerUsed = true;
        //    }
        //    else
        //    {
        //        MessageDialog messageDialog = new MessageDialog("כל הכבוד !! הצלחת למצוא את כל האתיות והמשחק הסתיים ");
        //        messageDialog.Commands.Add(new UICommand("שחק שוב", new UICommandInvokedHandler(this.CommandInvokedHandler1)));
        //        messageDialog.Commands.Add(new UICommand("חזרה לשיעור", new UICommandInvokedHandler(this.CommandInvokedHandler2)));
        //        await messageDialog.ShowAsync();
        //    }

        //}
        ///// <summary>
        ///// Preserves state associated with this page in case the application is suspended or the
        ///// page is discarded from the navigation cache.  Values must conform to the serialization
        ///// requirements of <see cref="SuspensionManager.SessionState"/>.
        ///// </summary>
        ///// <param name="pageState">An empty dictionary to be populated with serializable state.</param>
        //protected override void SaveState(Dictionary<String, Object> pageState)
        //{
        //    pageState.Add("game_pic_source", game_pic.Source);
        //    pageState.Add("mainGrid", mainGrid);
        //}

        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            if (pageState != null && pageState.ContainsKey("game_pic_source"))
            {
                game_pic.Source = pageState["game_pic_source"] as ImageSource;
            }
            if (pageState != null && pageState.ContainsKey("mainGrid"))
            {
                mainGrid = pageState["mainGrid"] as Grid;
            }
            currentLesson   = navigationParameter as Lesson;
            lessonHadLearnt = new HadLearnt(currentLesson);
            int    i = 0;
            int    x;
            Random r = new Random();

            //שלא יגריל יותר תמונות ממה שלמדו בשיעור
            if (lessonHadLearnt.pictuers_HadLearnt.Count() < 20)
            {
                count = lessonHadLearnt.pictuers_HadLearnt.Count() - 1;
            }
            //מכניס לליסטים נתונים באופן אקראי מהשיעורים שנלמדו
            for (int j = 0; j < count; j++)
            {
                //מגריל תמונה כל עוד לא ציון שהיא כבר הגיעה
                do
                {
                    x = r.Next(1, lessonHadLearnt.pictuers_HadLearnt.Count());
                }while (lessonHadLearnt.pictuers_HadLearnt[x].WordPictuerUsed == true);
                lessonHadLearnt.pictuers_HadLearnt[x].WordPictuerUsed = true;
                var picture = lessonHadLearnt.pictuers_HadLearnt[x];
                //הוספת טב לליסט
                images.Add(picture.WordPictuer);
                //lessonHadLearnt.pictuers_HadLearnt[j].WordPictuerUsed = true;
                tb.Add(new TextBlock()
                {
                    Text = picture.LettersBigShape, FontSize = 50, Foreground = new SolidColorBrush(Colors.LightGray)
                });
                tbWord.Add(new TextBlock()
                {
                    Text = picture.Word
                });
                sounds.Add(new MediaElement {
                    Source = new Uri(picture.WordSound)
                });
                tb[i++].Tapped += game_discoverThePicture_Tapped;
            }
            insertPictuer();
            insertTextBloke();
        }
Beispiel #3
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected async override void LoadState(object navigationParameter, Dictionary <String, Object> pageState)
        {
            currentLesson = navigationParameter as Lesson;
            int i = 0;

            lessonHadLearnt = new HadLearnt(currentLesson);

            tb   = new List <TextBlock>();
            img  = new List <Image>();
            mdel = new List <MediaElement>();

            tb_letter.Text = currentLesson.selectedLetter.ToUpper();

            //מציאת האות הנבחרת ללימוד והצגת תמונותיה
            foreach (var word in lessonHadLearnt.pictuers_HadLearnt)
            {
                if (word.LettersBigShape.Equals(currentLesson.selectedLetter) || word.LettersSmallShape.Equals(currentLesson.selectedLetter))
                {
                    //הוספת המילה
                    tb.Add(new TextBlock()
                    {
                        Text = word.Word, Foreground = new SolidColorBrush(Colors.Blue), FontSize = 25, TextAlignment = TextAlignment.Center
                    });

                    //הוספת השמע
                    mdel.Add(new MediaElement()
                    {
                        Source = new Uri(word.WordSound), Visibility = Windows.UI.Xaml.Visibility.Collapsed
                    });

                    //הוספת התמונה
                    img.Add(new Image()
                    {
                        Source = word.WordPictuer, Tag = 0.0, Height = 100, Width = 100
                    });
                }
            }
            //הפעלה
            var storyboard = new Storyboard();
            var Animation  = new DoubleAnimation
            {
                From     = 0,
                To       = 1,
                Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0)),
            };

            storyboard.Children.Add(Animation);

            Storyboard.SetTargetProperty(Animation, "Opacity");

            //1
            tb_Word1.Text     = tb[0].Text;
            mdel_Word1.Source = mdel[0].Source;
            mdel[0].Play();
            //await System.Threading.Tasks.Task.Delay(4000);
            //mdel[0].Stop();
            img_Word1.Source = img[0].Source;
            Storyboard.SetTarget(storyboard, img_Word1);

            storyboard.Begin();
            await System.Threading.Tasks.Task.Delay(4000);


            //2
            tb_Word2.Text     = tb[1].Text;
            mdel_Word2.Source = mdel[1].Source;
            mdel[1].Play();

            img_Word2.Source = img[1].Source;
            storyboard.Stop();
            Storyboard.SetTarget(storyboard, img_Word2);

            storyboard.Begin();
            storyboard.Stop();
            await System.Threading.Tasks.Task.Delay(4000);

            //3
            tb_Word3.Text     = tb[2].Text;
            mdel_Word3.Source = mdel[2].Source;
            mdel[2].Play();

            img_Word3.Source = img[2].Source;
            storyboard.Stop();
            Storyboard.SetTarget(storyboard, img_Word3);


            storyboard.Begin();
            await System.Threading.Tasks.Task.Delay(4000);

            //4
            tb_Word4.Text     = tb[3].Text;
            mdel_Word4.Source = mdel[3].Source;
            mdel[3].Play();


            img_Word4.Source = img[3].Source;
            storyboard.Stop();
            Storyboard.SetTarget(storyboard, img_Word4);


            storyboard.Begin();
        }