예제 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            buttonConnector = new ButtonModuleConnector();
            buttonConnector.OnModuleConnectionChange += ButtonConnector_OnModuleConnectionChange;
            buttonConnector.OnNewPortNames           += ButtonConnector_OnNewPortNames;
            buttonConnector.PortName = "COM4";
            buttonConnector.Init();

            registrationManager = new RegistrationManager();
            registrationManager.Init(buttonConnector);
            registrationManager.OnPlayerDisable     += RegistrationManager_OnPlayerDisable;
            registrationManager.OnPlayerRegistrated += RegistrationManager_OnPlayerRegistrated;

            dbWorker = new DataBaseWorker();
            dbWorker.Init();
            QuizInfo playersInfo = dbWorker.GetFullInfo();

            RoundNumber = playersInfo.RoundIndex;

            quizManager = new QuizManager();
            quizManager.OnNewQuestion         += QuizManager_OnNewQuestion;
            quizManager.OnPlayerButtonClicked += QuizManager_OnPlayerButtonClicked;
            quizManager.OnRightAnswer         += QuizManager_OnRightAnswer;
            quizManager.OnWrongAnswer         += QuizManager_OnWrongAnswer;
            quizManager.OnRoundEnd            += QuizManager_OnRoundEnd;
            quizManager.Init(dbWorker.GetQuestions(), buttonConnector);

            if (playersInfo.PlayersNames.Count == 0)
            {
                AddPlayer();
                AddPlayer();
            }
            else
            {
                for (int i = 0; i < playersInfo.PlayersNames.Count; ++i)
                {
                    AddPlayer(playersInfo.PlayersNames[i]);
                    AddPoints(i, playersInfo.PlayersPoints[i]);
                }
            }

            MediaBlock.LoadedBehavior   = MediaState.Manual;
            MediaBlock.UnloadedBehavior = MediaState.Manual;
            MediaBlock.Volume           = 0.5f;

            RightAnswerMediaBlock.LoadedBehavior   = MediaState.Manual;
            RightAnswerMediaBlock.UnloadedBehavior = MediaState.Manual;
            RightAnswerMediaBlock.Volume           = 0.5f;

            Sound.LoadedBehavior   = MediaState.Manual;
            Sound.UnloadedBehavior = MediaState.Manual;
            Sound.Volume           = 0.5f;

            Sound.Stop();
        }
예제 #2
0
 public MainWindow()
 {
     InitializeComponent();
     _quizManager = FindResource("QuizManager") as QuizManager;
 }