Ejemplo n.º 1
0
        public void GenPrev()
        {
            QAInstance instance = QADictionary.BackToPreviousQuestion();

            if (instance != null)
            {
                AnswerTB.Text   = instance.Answer;
                QuestionTB.Text = instance.Question;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create the next question in the user interface in case the XML file exists.
        /// </summary>
        public void GenNext()
        {
            QAInstance instance = QADictionary.GenerateNextQuestion();

            if (instance == null)
            {
                MessageBox.Show($"No records found in the XML file.");
            }
            else
            {
                AnswerTB.Text   = instance.Answer;
                QuestionTB.Text = instance.Question;
            }
        }
Ejemplo n.º 3
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            if (EditMode)  // Disabling UI edit mode
            {
                if (MessageBox.Show("Save changes?", "Apply?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    QAInstance instance = new QAInstance(QuestionTB.Text, AnswerTB.Text);
                    new XMLWorker(System.IO.Directory.GetCurrentDirectory() + Properties.Settings.Default.XMLname).UpdateExisting(
                        new QAInstance(QuestionValue, AnswerValue), new QAInstance(QuestionTB.Text, AnswerTB.Text));
                }
                else
                {
                    QuestionTB.Text = QuestionValue;
                    AnswerTB.Text   = AnswerValue;
                }
                EditMode = false;

                AnswerTB.Background = Brushes.Transparent;

                QuestionTB.Background = Brushes.Transparent;
                EditButton.Content    = "Edit";
                QuestionValue         = null;
                AnswerValue           = null;
                QADictionary.ReloadDictionary();

                ControlEnableInvert(new FrameworkElement[] { AddButton, Next, Previous });

                AnswerTB.IsReadOnly   = true;
                QuestionTB.IsReadOnly = true;
            }
            else // Edit mode in UI
            {
                AnswerValue           = AnswerTB.Text;
                QuestionValue         = QuestionTB.Text;
                EditMode              = true;
                EditButton.Content    = "Save";
                AnswerTB.Background   = Brushes.WhiteSmoke;
                QuestionTB.Background = Brushes.WhiteSmoke;

                ControlEnableInvert(new FrameworkElement[] { AddButton, Next, Previous });

                AnswerTB.IsReadOnly   = false;
                QuestionTB.IsReadOnly = false;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// On closing this windows
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void AddWindowsClosed(object sender, EventArgs e)
 {
     QADictionary.ReloadDictionary();
 }
Ejemplo n.º 5
0
 public MainWindow()
 {
     InitializeComponent();
     QADictionary.ReloadDictionary();
     GenNext();
 }