Example #1
0
        /// <summary>
        /// Affiche des informations sur le jeu selectionné
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Bt_MouseEnter(object sender, MouseEventArgs e)
        {
            if (this.currentCourseInfo != null && this.mainMenuContentGrid.Children.Contains(this.currentCourseInfo))
            {
                this.mainMenuContentGrid.Children.Remove(this.currentCourseInfo);
            }
            Button bt = (Button)sender;

            if (bt.Tag != null && bt.Tag is Datas.Game)
            {
                Datas.Game tag        = bt.Tag as Datas.Game;
                string     courseName = (from i in Bdd.DbAccess.Courses where i.ID == tag.idCourse select i).FirstOrDefault().name;
                int        score      = 0;
                int        nbGame     = 0;
                try
                {
                    score  = (int)(from i in Bdd.DbAccess.Scores where i.idGame == tag.ID && i.idUser == App.user.ID select i.value).Max();
                    nbGame = (from i in Bdd.DbAccess.Scores where i.idGame == tag.ID && i.idUser == App.user.ID select i).Count();
                }
                catch (Exception)
                {
                }

                UIElement cci = new CourseInformations(tag.name, App.user.Grade.name, courseName, tag.description, score, nbGame);
                this.currentCourseInfo = cci;
                this.mainMenuContentGrid.Children.Add(this.currentCourseInfo);
            }
        }
Example #2
0
        /// <summary>
        /// Lance un jeu à partir de son nom dans la bdd
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LaunchGame(object sender, EventArgs e)
        {
            Button bt = (Button)sender;

            if (bt.Tag != null && bt.Tag is Datas.Game)
            {
                Datas.Game tag = bt.Tag as Datas.Game;
                try
                {
                    if (tag.className == "QuestionaryControl")
                    {
                        int id = (int)tag.idQuestionary;
                        App.mainWindow.LaunchGame(new QuestionaryControl(App.user.ID, tag.ID, -1, id));
                    }
                    else
                    {
                        Type   game = Type.GetType("EducationAll.Games." + tag.className);
                        object o    = Activator.CreateInstance(game, App.user.ID, tag.ID, -1);
                        App.mainWindow.LaunchGame(o as IGame);
                    }
                }
                catch (Exception)
                {
                    ErrorWindow wd = new ErrorWindow(false);
                    wd.Owner = App.mainWindow;
                    wd.ShowDialog();
                }
            }
        }
        /// <summary>
        /// Lance le jeu du défi selectionné
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Cb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ChallengeButton s = sender as ChallengeButton;

            if (s.Tag != null)
            {
                Datas.Dual d    = s.Tag as Datas.Dual;
                Datas.Game game = (from i in Bdd.DbAccess.Games where d.idGame == i.ID select i).FirstOrDefault();
                try
                {
                    if (game.className == "QuestionaryControl")
                    {
                        int id = (int)game.idQuestionary;
                        App.mainWindow.LaunchGame(new QuestionaryControl(App.user.ID, game.ID, d.ID, id));
                    }
                    else
                    {
                        Type   game1 = Type.GetType("EducationAll.Games." + game.className);
                        object o     = Activator.CreateInstance(game1, App.user.ID, game.ID, d.ID);
                        App.mainWindow.LaunchGame(o as IGame);
                    }
                }
                catch (Exception)
                {
                    ErrorWindow wd = new ErrorWindow(false);
                    wd.Owner = App.mainWindow;
                    wd.ShowDialog();
                }
            }
        }