Esempio n. 1
0
 private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MainTeacherCommentTextBox != null)
     {
         MainTeacherCommentTextBox.Focus();
     }
 }
Esempio n. 2
0
        private void TrimesterComment_KeyDown(object sender, KeyEventArgs e)
        {
            EntryTrimesterCommentsViewModel entryTrimesterComments = (EntryTrimesterCommentsViewModel)DataContext;

            switch (e.Key)
            {
                case Key.Down:
                    {
                        TextBox textBox = (TextBox)sender;
                        if (textBox == MainTeacherCommentTextBox)
                        {
                            DivisionPrefectCommentTextBox.Focus();
                        }
                        else if (textBox == DivisionPrefectCommentTextBox)
                        {
                            SaveTrimesterComments(entryTrimesterComments);
                            if (entryTrimesterComments.SelectedClass.SelectedStudent != entryTrimesterComments.SelectedClass.Students.Last())
                            {
                                entryTrimesterComments.SelectedClass.SelectedStudent
                                    = entryTrimesterComments.SelectedClass.Students[entryTrimesterComments.SelectedClass.Students.IndexOf(entryTrimesterComments.SelectedClass.SelectedStudent) + 1];
                            }
                            else
                            {
                                if (entryTrimesterComments.SelectedClass != entryTrimesterComments.Classes.Last())
                                {
                                    entryTrimesterComments.SelectedClass = entryTrimesterComments.Classes[entryTrimesterComments.Classes.IndexOf(entryTrimesterComments.SelectedClass) + 1];
                                }
                                else
                                {
                                    MessageBox.Show("Fin de la saisie.", "Fin", MessageBoxButton.OK, MessageBoxImage.Information);
                                }
                            }
                        }
                        e.Handled = true;
                    }
                    break;
                case Key.Up:
                    {
                        TextBox textBox = (TextBox)sender;
                        if (textBox == DivisionPrefectCommentTextBox)
                        {
                            MainTeacherCommentTextBox.Focus();
                        }
                        else if (textBox == MainTeacherCommentTextBox)
                        {
                            SaveTrimesterComments(entryTrimesterComments);
                            if (entryTrimesterComments.SelectedClass.SelectedStudent != entryTrimesterComments.SelectedClass.Students.First())
                            {
                                entryTrimesterComments.SelectedClass.SelectedStudent
                                    = entryTrimesterComments.SelectedClass.Students[entryTrimesterComments.SelectedClass.Students.IndexOf(entryTrimesterComments.SelectedClass.SelectedStudent) - 1];
                            }
                            else
                            {
                                if (entryTrimesterComments.SelectedClass != entryTrimesterComments.Classes.First())
                                {
                                    entryTrimesterComments.SelectedClass = entryTrimesterComments.Classes[entryTrimesterComments.Classes.IndexOf(entryTrimesterComments.SelectedClass) - 1];
                                    entryTrimesterComments.SelectedClass.SelectedStudent = entryTrimesterComments.SelectedClass.Students.FirstOrDefault();
                                }
                            }
                        }
                        e.Handled = true;
                    }
                    break;
            }
        }