private void Window_KeyDown(object sender, KeyEventArgs e) { if (ProfilePopup.Visibility == Visibility.Hidden) { switch (e.Key) { case Key.Right: if (currentButtonSelectionIndex != 2 && currentButtonSelectionIndex != 5 && currentButtonSelectionIndex != 8 && currentButtonSelectionIndex != 9) { resetButtonFocus(currentButtonSelectionIndex); currentButtonSelectionIndex = (currentButtonSelectionIndex + 1) % 9; setButtonFocus(currentButtonSelectionIndex); } break; case Key.Left: if (currentButtonSelectionIndex != 0 && currentButtonSelectionIndex != 3 && currentButtonSelectionIndex != 6 && currentButtonSelectionIndex != 9) { resetButtonFocus(currentButtonSelectionIndex); currentButtonSelectionIndex = (currentButtonSelectionIndex - 1) % 9; setButtonFocus(currentButtonSelectionIndex); } break; case Key.Down: if (currentButtonSelectionIndex == 9) { resetButtonFocus(currentButtonSelectionIndex); currentButtonSelectionIndex = 0; setButtonFocus(currentButtonSelectionIndex); } else if (currentButtonSelectionIndex < 6) { resetButtonFocus(currentButtonSelectionIndex); currentButtonSelectionIndex = (currentButtonSelectionIndex + 3) % 9; setButtonFocus(currentButtonSelectionIndex); } break; case Key.Up: if (currentButtonSelectionIndex >= 3 && currentButtonSelectionIndex != 9) { resetButtonFocus(currentButtonSelectionIndex); currentButtonSelectionIndex = (currentButtonSelectionIndex - 3) % 9; setButtonFocus(currentButtonSelectionIndex); } else { resetButtonFocus(currentButtonSelectionIndex); currentButtonSelectionIndex = 9; setButtonFocus(currentButtonSelectionIndex); } break; case Key.Z: if (e.Key == Key.Z) { //hardcoded to show notification Notification_popup0.Visibility = Visibility.Visible; //notifyDot.Visibility = Visibility.Visible; dispatcherTimer.Start(); } break; case Key.S: Settings settings = new Settings(); settings.Show(); this.Close(); break; case Key.G: TV_Guide tv = new TV_Guide(); tv.Show(); this.Close(); break; case Key.OemQuestion: Settings setting = new Settings(); setting.Show(); this.Close(); break; case Key.O: /*{ "Live TV", "Image/tv_icon.png" }, { "Gallery", "Image/gallery_icon.png" }, { "Music", "Image/music_icon.png" }, { "Recordings", "Image/record_icon.png" }, { "Search", "Image/search_icon.jpg" }, { "Netflix", "Image/netflix_icon.png" }, { "Settings", "Image/settings_icon.png" }, { "Notification", "Image/notification_icon.png" }, { "Other Apps", "Image/apps_icon.png" } , {"John Doe","Image/profile_icon.png" }*/ if (Notification_popup0.Visibility != Visibility.Visible) { bool dontClose = false; resetButtonFocus(currentButtonSelectionIndex); switch (content[currentButtonSelectionIndex, 0]) { case "Live TV": TV_Guide tvG = new TV_Guide(); tvG.Show(); break; case "Gallery": Photos_Videos gallery = new Photos_Videos(); gallery.Show(); break; case "Music": Music music = new Music(); music.Show(); break; case "Recordings": Recordings rec = new Recordings(); rec.Show(); break; case "Search": Search search = new Search(); search.Show(); break; case "Netflix": dontClose = true; MessageBox.Show("No screens made for third party"); break; case "Settings": Settings2 sett = new Settings2(); sett.Show(); break; case "Notification": Notification_tab notif = new Notification_tab(); notif.Show(); //notifyDot.Visibility = Visibility.Hidden; break; case "Other Apps": OtherApplications otherApp = new OtherApplications(); otherApp.Show(); content[6, 0] = "Prime Videos"; content[6, 1] = "Image/primevid_icon.png"; updateContent(6); break; default: //profile MainGrid.Effect = new BlurEffect(); dontClose = true; profileBtns.Clear(); ProfilePopup.Visibility = Visibility.Visible; Profiles_header.Visibility = Visibility.Visible; for (int i = 0; i < 2; i++) { Button profile = new Button(); profile.HorizontalContentAlignment = HorizontalAlignment.Center; StackPanel sPanel1 = new StackPanel(); sPanel1.HorizontalAlignment = HorizontalAlignment.Center; sPanel1.Orientation = Orientation.Vertical; Image image = new Image(); Uri imageUri = new Uri(profiles[i, 1], UriKind.Relative); image.Source = new BitmapImage(imageUri); image.Height = 55; image.Width = 55; sPanel1.Children.Add(image); profile.Name = "profile" + i.ToString(); TextBox textBox = new TextBox(); textBox.Background = Brushes.Transparent; textBox.Text = profiles[i, 0]; textBox.BorderBrush = Brushes.Transparent; profile.Height = 90; profile.Width = 170; textBox.FontSize = 20; sPanel1.Children.Add(textBox); profile.Content = sPanel1; profile.Background = (LinearGradientBrush)FindResource("ButtonNormalBackground"); profileBtns.Add(profile); ProfilePopup.Children.Add(profile); } //ProfilePopup.Children.Add setProfileButtonFocus(profileIndex); //Console.WriteLine(profileIndex); break; } if (!dontClose) { updateContent(currentButtonSelectionIndex); currentButtonSelectionIndex = 0; this.Close(); } } else { if (e.Key == Key.O) { LiveTV liveTV = new LiveTV(2); //notifyDot.Visibility = Visibility.Hidden; liveTV.Show(); this.Close(); } } break; default: break; } } else { } }
// Keyboard manouvering! private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Back) { // Backspace = go back to previous screen (Main menu?) // TODO: hard code this for the demo to fake "saved state" MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } else if (e.Key == Key.S) // "remote" clicks s = search { Search search = new Search(); search.Show(); this.Close(); } else if (e.Key == Key.H) // go home { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } // The "janky, but it works" method of keyboard navigation. else if (e.Key == Key.Down) { if (_slider_TextSize.IsFocused) { _combobox_Language.Focus(); } else if (_combobox_Language.IsFocused) { _togbut_ButtonGuide.Focus(); } else if (_togbut_ButtonGuide.IsFocused) { _button_AdvanceSettings.Focus(); } else if (_button_AdvanceSettings.IsFocused) { _slider_TextSize.Focus(); } } else if (e.Key == Key.Up) { if (_slider_TextSize.IsFocused) { _button_AdvanceSettings.Focus(); } else if (_combobox_Language.IsFocused) { _slider_TextSize.Focus(); } else if (_togbut_ButtonGuide.IsFocused) { _combobox_Language.Focus(); } else if (_button_AdvanceSettings.IsFocused) { _togbut_ButtonGuide.Focus(); } } else if (e.Key == Key.O) { if (_slider_TextSize.IsFocused) { _combobox_Language.Focus(); } else if (_combobox_Language.IsFocused) { _slider_TextSize.Focus(); } else if (_togbut_ButtonGuide.IsFocused) { // Trigger _togbut_ButtonGuide.IsChecked; } else if (_button_AdvanceSettings.IsFocused) { AdSet_button_Click(sender, e); } } else if (e.Key == Key.Z) // Make button guide window pop up { if (_togbut_ButtonGuide.IsFocused) { Settings2 settings2 = new Settings2(); settings2.Show(); this.Close(); } } }