// Adds the course buttons. public void addButtons(SortedList <String, CourseItem> courseList) { // Electrical has 30 4th year courses!!! Grid fadeIn = fadePanels[currrentPanel++ % 2]; Grid fadeOut = fadePanels[currrentPanel % 2]; StackPanel[] cols = { fadeIn.Children[0] as StackPanel, fadeIn.Children[1] as StackPanel, fadeIn.Children[2] as StackPanel, fadeIn.Children[3] as StackPanel }; // Clear old courses. foreach (StackPanel c in cols) { c.Children.Clear(); } //cols = new StackPanel[]{ fadeIn.Children[0] as StackPanel, fadeIn.Children[1] as StackPanel, fadeIn.Children[2] as StackPanel, fadeIn.Children[3] as StackPanel }; // Actually add courses. int currentCol = 0; foreach (KeyValuePair <String, CourseItem> kvp in courseList) { CourseButton button = new CourseButton() { CourseTitle = kvp.Value.Name, CourseCode = kvp.Key, CourseItem = kvp.Value }; button.PreviewTouchDown += ClickCourse; button.PreviewMouseDown += ClickCourse; cols[currentCol].Children.Add(button); currentCol = (currentCol + 1) % cols.Length; // Add courses to lines alternatively (eg: line 1, 2, 1, 2 etc). //panelLines[line++ % panelLines.Count()].Children.Add(button); // Make button the colour of that specialisation. setButtonColour(button); } fadeIn.Opacity = 0; Storyboard sb1 = (Storyboard)Resources["FadeOut"]; Storyboard sb2 = (Storyboard)Resources["FadeIn"]; sb1.Completed += FadeOut_Completed; sb1.SeekAlignedToLastTick(new TimeSpan(0, 0, 10)); sb2.SeekAlignedToLastTick(new TimeSpan(0, 0, 10)); MainScrollViewer.ScrollToTop(); sb1.Begin(fadeOut); sb2.Begin(fadeIn); }
private void setButtonColour(CourseButton button) { if (ProgramTitle.Equals((string)Application.Current.FindResource("CSE_Courses_Title"))) { button.Button.Background = (SolidColorBrush)Application.Current.FindResource("Colour_CSE"); } else if (ProgramTitle.Equals((string)Application.Current.FindResource("EEE_Courses_Title"))) { button.Button.Background = (SolidColorBrush)Application.Current.FindResource("Colour_EEE"); } else if (ProgramTitle.Equals((string)Application.Current.FindResource("SE_Courses_Title"))) { button.Button.Background = (SolidColorBrush)Application.Current.FindResource("Colour_SE"); } }
private void setButtonColour(CourseButton button) { if (ProgramTitle.Equals((string)Application.Current.FindResource("CSE_Courses_Title"))) button.Button.Background = (SolidColorBrush)Application.Current.FindResource("Colour_CSE"); else if (ProgramTitle.Equals((string)Application.Current.FindResource("EEE_Courses_Title"))) button.Button.Background = (SolidColorBrush)Application.Current.FindResource("Colour_EEE"); else if (ProgramTitle.Equals((string)Application.Current.FindResource("SE_Courses_Title"))) button.Button.Background = (SolidColorBrush)Application.Current.FindResource("Colour_SE"); }
// Adds the course buttons. public void addButtons(SortedList<String, CourseItem> courseList) { // Electrical has 30 4th year courses!!! Grid fadeIn = fadePanels[currrentPanel++ % 2]; Grid fadeOut = fadePanels[currrentPanel % 2]; StackPanel[] cols = { fadeIn.Children[0] as StackPanel, fadeIn.Children[1] as StackPanel, fadeIn.Children[2] as StackPanel, fadeIn.Children[3] as StackPanel }; // Clear old courses. foreach (StackPanel c in cols) { c.Children.Clear(); } //cols = new StackPanel[]{ fadeIn.Children[0] as StackPanel, fadeIn.Children[1] as StackPanel, fadeIn.Children[2] as StackPanel, fadeIn.Children[3] as StackPanel }; // Actually add courses. int currentCol = 0; foreach (KeyValuePair<String, CourseItem> kvp in courseList) { CourseButton button = new CourseButton() { CourseTitle = kvp.Value.Name, CourseCode = kvp.Key, CourseItem = kvp.Value }; button.PreviewTouchDown += ClickCourse; button.PreviewMouseDown += ClickCourse; cols[currentCol].Children.Add(button); currentCol = (currentCol + 1) % cols.Length; // Add courses to lines alternatively (eg: line 1, 2, 1, 2 etc). //panelLines[line++ % panelLines.Count()].Children.Add(button); // Make button the colour of that specialisation. setButtonColour(button); } fadeIn.Opacity = 0; Storyboard sb1 = (Storyboard)Resources["FadeOut"]; Storyboard sb2 = (Storyboard)Resources["FadeIn"]; sb1.Completed += FadeOut_Completed; sb1.SeekAlignedToLastTick(new TimeSpan(0, 0, 10)); sb2.SeekAlignedToLastTick(new TimeSpan(0, 0, 10)); MainScrollViewer.ScrollToTop(); sb1.Begin(fadeOut); sb2.Begin(fadeIn); }
public void ClickCourse(object sender, InputEventArgs e) { CourseButton cb = sender as CourseButton; CurrentCourse = cb.CourseItem; }