Exemplo n.º 1
0
        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyboardDevice.Modifiers == ModifierKeys.Alt &&
                e.SystemKey == Key.Left)
            {
                controller.MoveToPreviousQuestion();
            }
            else if (e.KeyboardDevice.Modifiers == ModifierKeys.Alt &&
                     e.SystemKey == Key.Right)
            {
                controller.MoveToNextQuestion();
            }
            else if (e.KeyboardDevice.Modifiers == ModifierKeys.Control &&
                     e.Key == Key.D)
            {
                RemoveQuestion.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));

                // Stop the character from being entered in textboxes
                e.Handled = true;
            }
            else if (e.KeyboardDevice.Modifiers == ModifierKeys.Control &&
                     e.Key == Key.S)
            {
                SaveQuestions.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));

                // Stop the character from being entered in textboxes
                e.Handled = true;
            }
            else if (e.Key == Key.Escape)
            {
                CloseCreator.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
Exemplo n.º 2
0
        public void SaveAndSwitchToMainWindow()
        {
            MessageBoxResult decision = MessageBox.Show(
                "Do you want to save question set before closing?",
                "Question",
                MessageBoxButton.YesNo
                );

            if (decision == MessageBoxResult.Yes)
            {
                SaveQuestions.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }

            SwitchToMainWindow();
        }
Exemplo n.º 3
0
        public async Task DeleteQuestion(string questionId)
        {
            int      qId = int.Parse(questionId);
            Question questionToDelete = Program.Questions[qId];

            if (Context.User.Id == Program.OwnerID)
            {
                await Context.Channel.SendMessageAsync($"Question No.{qId} successfully deleted!");

                Program.Questions.RemoveAt(qId);

                //Save game questions to JSON file
                SaveQuestions savedQuestions = new SaveQuestions(Program.Questions);
            }
            else
            {
                await Context.Channel.SendMessageAsync("Only the owner can delete questions!");
            }
            //To-Do: Have confirmation dialogue
        }
Exemplo n.º 4
0
        public async Task AddNewQuestion(string text, string answer, string category, string difficulty)
        {
            //Check if question already exists
            foreach (Question q in Program.Questions)
            {
                if (q.Text == text)
                {
                    await Context.Channel.SendMessageAsync($"Question \"{text}\" already exists!");

                    return;
                }
            }
            Program.Questions.Add(new Question(text, answer, category, difficulty));
            await Context.Channel.SendMessageAsync($"Question \"{text}\" with correct answer \"{answer}\" has been successfully added");

            //Save game questions to JSON file
            SaveQuestions savedQuestions = new SaveQuestions(Program.Questions);

            return;
        }