Beispiel #1
0
        public override void Execute(object parameter)
        {
            OnlineExamsViewModel onlineExamsViewModel = new OnlineExamsViewModel();
            OnlineExamControl    onlineExamControl    = new OnlineExamControl();

            onlineExamsViewModel.SingleQuestionPanel = onlineExamControl.SingleQuestionPanel;
            onlineExamControl.DataContext            = onlineExamsViewModel;

            for (int i = 0; i < 25; i++) // or iterate in DB.Questions
            {
                SingleQuestionViewModel questionViewModel = new SingleQuestionViewModel();
                questionViewModel.Question = "TEST" + i;

                SingleQuestionControl control = new SingleQuestionControl();
                control.DataContext = questionViewModel;

                onlineExamsViewModel.QuestionControls.Add(control);
            }

            MainWindow mainWindow = (MainWindow)mainViewModel.Window;

            mainWindow.GrdCenter.Children.Clear();
            mainWindow.GrdCenter.Children.Add(onlineExamControl);

            onlineExamsViewModel.CurrentQuestion = 0;
        }
Beispiel #2
0
        public GameWindow(Game game)
        {
            InitializeComponent();

            if (game == null || game.NumRounds < 2)
            {
                throw new ArgumentException("Game cannot be null and must have at least two rounds");
            }

            mGame = game;

            mSoundPlayerIntro.Load();

            mAttachedKeys = new List <Key>()
            {
                Key.D1, Key.D2, Key.D3, Key.D4, Key.D5, Key.D6, Key.D7, Key.D8, Key.D9, Key.D0
            };

            switch (mGame.BonusRoundLocation)
            {
            case BonusRoundLocation.Middle:
                mBonusRoundIndex  = (int)(game.NumRounds / 2);
                ExistingQuestions = new IRoundControl[mGame.NumRounds + 1];
                break;

            case BonusRoundLocation.End:
                mBonusRoundIndex  = (int)game.NumRounds;
                ExistingQuestions = new IRoundControl[mGame.NumRounds + 1];
                break;

            case BonusRoundLocation.None:
            default:
                mBonusRoundIndex  = int.MaxValue;
                ExistingQuestions = new IRoundControl[mGame.NumRounds];
                break;
            }

            for (int i = 0; i < ExistingQuestions.Length; i++)
            {
                if (i == mBonusRoundIndex)
                {
                    var bonusRound = new BonusRoundControl(game.BonusRound);
                    bonusRound.OnTimerFinished += (sender, args) =>
                    {
                        OnTimerFinished?.Invoke(sender, args);
                    };
                    ExistingQuestions[i] = bonusRound;
                }
                else
                {
                    int normalQuestionIndex = i <= mBonusRoundIndex ? i : i - 1;
                    ExistingQuestions[i] = new SingleQuestionControl(mGame.Rounds.ElementAt(normalQuestionIndex));
                }

                (ExistingQuestions[i] as UIElement).CacheMode = new BitmapCache()
                {
                    EnableClearType = false, RenderAtScale = 1, SnapsToDevicePixels = false
                };
            }

            IntroPlaceholderBorder = new Border()
            {
                Background = new SolidColorBrush(Color.FromRgb(0, 0, 0))
            };

            gParentGrid.Children.Add(IntroPlaceholderBorder);

            mNextQuestion = ExistingQuestions[0];
            SetNextTransform(mNextQuestion);
            gParentGrid.Children.Add(mNextQuestion as Control);

            mMediaPlayerQuestion = new MediaPlayer();

            mMediaPlayerQuestion.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"/Sounds/Next_Question.wav", UriKind.RelativeOrAbsolute));
            mMediaPlayerQuestion.IsMuted = true;

            this.Closed += GameWindow_Closed;
        }