Exemple #1
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();
                }
            }
        }
        private void Error()
        {
            ErrorWindow wd = new ErrorWindow(false);

            wd.Owner = App.mainWindow;
            wd.ShowDialog();
            this.Bcontinue_Click(null, null);
        }
Exemple #4
0
        /// <summary>
        /// Affiche les rangs dans la combo box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            List <Datas.Rank> ranks = new List <Datas.Rank>();

            try
            {
                ranks = Bdd.DbAccess.Ranks.ToList();
            }
            catch (Exception)
            {
                App.mainWindow.Close();
                ErrorWindow wd = new ErrorWindow(true);
                wd.ShowDialog();
            }
            foreach (Datas.Rank rank in ranks)
            {
                this.cBRank.Items.Add(rank);
            }
            if (ranks.Count > 0)
            {
                this.cBRank.SelectedItem = this.cBRank.Items.GetItemAt(0);
            }
        }
Exemple #5
0
        /// <summary>
        /// Affiche les grades dans la combo box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            List <Datas.Grade> grades = new List <Datas.Grade>();

            try
            {
                grades = Bdd.DbAccess.Grades.ToList();
            }
            catch (Exception)
            {
                App.mainWindow.Close();
                ErrorWindow wd = new ErrorWindow(true);
                wd.ShowDialog();
            }
            foreach (Datas.Grade grade in grades)
            {
                this.comboBoxInscrForm.Items.Add(grade);
            }
            if (grades.Count > 0)
            {
                this.comboBoxInscrForm.SelectedItem = this.comboBoxInscrForm.Items.GetItemAt(0);
            }
            this.textBoxConn.Focus();
        }