Beispiel #1
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Back)
     {
         text = "";
         MainWindow mainWindow = new MainWindow();
         mainWindow.Show();
         this.Close();
     }
     else if (e.Key == Key.H)
     {
         MainWindow mainWindow = new MainWindow();
         mainWindow.Show();
         this.Close();
     }
     if (e.Key == Key.OemQuestion)
     {
         Settings settingsWindow = new Settings();
         settingsWindow.Show();
         this.Close();
     }
     else if (e.Key == Key.S)
     {
         if (keypad.Visibility == Visibility.Hidden)
         {
             counter.Visibility    = Visibility.Hidden;
             searchBox.BorderBrush = Brushes.CornflowerBlue;
             keypad.Visibility     = Visibility.Visible;
             scroll.Width         -= 270;
             scroll.Margin         = new Thickness(270, 0, 0, 0);
             update = false;
             ((Grid)keypad.Children[1]).Children[0].Focus();
         }
         else if (keypad.Visibility == Visibility.Visible && update)
         {
             counter.Visibility    = Visibility.Visible;
             searchBox.BorderBrush = Brushes.DarkGray;
             keypad.Visibility     = Visibility.Hidden;
             scroll.Width         += 270;
             scroll.Margin         = new Thickness();
             if (stack.Children.Count > 0)
             {
                 ((Grid)stack.Children[1]).Children[1].Focus();
             }
         }
         else
         {
             update = true;
         }
     }
     else if (e.Key == Key.OemQuestion)
     {
         Settings settings = new Settings();
         settings.Show();
         this.Close();
     }
     else if (e.Key == Key.G)
     {
         TV_Guide guide = new TV_Guide();
         guide.Show();
         this.Close();
     }
 }
Beispiel #2
0
        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.OemPlus:
                    Vol1.Visibility = Visibility.Visible;
                    Vol2.Visibility = Visibility.Visible;
                    Vol.Visibility  = Visibility.Visible;
                    volume         += 2;
                    Vol.Content     = volume;
                    if (volume >= 45 && volume < 50)
                    {
                        Vol2.Margin = new Thickness(724, 368, 0, 0);
                    }
                    if (volume >= 50)
                    {
                        Vol2.Margin = new Thickness(697, 377, 0, 0);
                    }
                    dispatcherTimer.Start();
                    break;

                case Key.OemMinus:
                    Vol1.Visibility = Visibility.Visible;
                    Vol2.Visibility = Visibility.Visible;
                    Vol.Visibility  = Visibility.Visible;
                    volume         -= 2;
                    Vol.Content     = volume;
                    if (volume >= 45 && volume < 50)
                    {
                        Vol2.Margin = new Thickness(724, 368, 0, 0);
                    }
                    if (volume < 45)
                    {
                        Vol2.Margin = new Thickness(742, 351, 0, 0);
                    }
                    dispatcherTimer.Start();
                    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":
                            Settings sett = new Settings();
                            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
            {
                switch (e.Key)
                {
                case Key.Back:

                    if (addingProfilePopup.Visibility == Visibility.Hidden)
                    {
                        MainGrid.Effect = null;
                        ProfilePopup.Children.Clear();
                        ProfilePopup.Visibility    = Visibility.Hidden;
                        Profiles_header.Visibility = Visibility.Hidden;
                        setButtonFocus(currentButtonSelectionIndex);
                        resetProfileButtonFocus(profileIndex);
                        profileIndex = 0;
                    }
                    else
                    {
                        ProfilePopup.Effect           = null;
                        addingProfilePopup.Visibility = Visibility.Hidden;
                        keypad.Visibility             = Visibility.Hidden;
                        BackOption.Visibility         = Visibility.Hidden;
                    }
                    break;

                case Key.Right:
                    if (addingProfilePopup.Visibility == Visibility.Hidden)
                    {
                        resetProfileButtonFocus(profileIndex);
                        profileIndex = (profileIndex + 1) % 2;
                        setProfileButtonFocus(profileIndex);
                    }
                    break;

                case Key.Left:
                    if (addingProfilePopup.Visibility == Visibility.Hidden)
                    {
                        resetProfileButtonFocus(profileIndex);
                        profileIndex = (profileIndex - 1);
                        if (profileIndex == -1)
                        {
                            profileIndex = 1;
                        }
                        setProfileButtonFocus(profileIndex);
                    }
                    break;

                case Key.O:
                    if (addingProfilePopup.Visibility == Visibility.Hidden)
                    {
                        ProfilePopup.Effect           = new BlurEffect();
                        addingProfilePopup.Visibility = Visibility.Visible;
                        keypad.Visibility             = Visibility.Visible;
                        BackOption.Visibility         = Visibility.Visible;
                    }
                    break;

                default:
                    break;
                }
            }
        }
        //FOLLOWING CODE IS NOT BEING USED******************************************

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Back)
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
            if (e.Key == Key.H)
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
            if (e.Key == Key.Z)
            { //hardcoded to show notification
                Notification_popup0.Visibility = Visibility.Visible;
                dispatcherTimer.Start();
            }
            if (e.Key == Key.S)
            {
                Settings settings = new Settings();
                settings.Show();
                this.Close();
            }
            if (e.Key == Key.G)
            {
                TV_Guide tvg = new TV_Guide();
                tvg.Show();
                this.Close();
            }
            if (e.Key == Key.OemQuestion)
            {
                Settings setting = new Settings();
                setting.Show();
                this.Close();
            }


            if (Notification_popup0.Visibility == Visibility.Visible)
            {
                if (e.Key == Key.O)
                {
                    LiveTV liveTV = new LiveTV(2);
                    liveTV.Show();
                    this.Close();
                }
            }
            else
            {
                if (e.Key == Key.O)
                {
                    content[selectedIndex, 0] = "Settings";
                    content[selectedIndex, 1] = "Image/settings_icon.png";
                    /* amazon prime page*/
                    Amazon pr = new Amazon();
                    pr.Show();
                    this.Close();
                }
            }
        }
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.I && !hidden)
            {
                //sidemenu.Margin = new Thickness(-400, 0, 400, 0);
                hidden = true;

                Storyboard sb = sidemenu.FindResource("SlideLeft") as Storyboard;
                if (sb != null)
                {
                    BeginStoryboard(sb);
                }
            }
            else if (e.Key == Key.I && hidden)
            {
                //sidemenu.Margin = new Thickness(0, 0, 0, 0);
                hidden = false;
                Storyboard sb = sidemenu.FindResource("SlideRight") as Storyboard;
                if (sb != null)
                {
                    BeginStoryboard(sb);
                }
            }
            else if (e.Key == Key.Right)
            {
            }
            else if (e.Key == Key.Left)
            {
            }
            else if (e.Key == Key.Back || e.Key == Key.G)
            {
                TV_Guide tvguide = new TV_Guide();
                tvguide.Show();
                this.Close();
            }


            else if (e.Key == Key.OemQuestion)
            {
                Settings settings = new Settings();
                settings.Show();
                this.Close();
            }

            else if (e.Key == Key.S)
            {
                Search search = new Search();
                search.Show();
                this.Close();
            }
            else if (e.Key == Key.H)
            {
                MainWindow mainw = new MainWindow();
                mainw.Show();
                this.Close();
            }

            else if (e.Key == Key.Z)
            {
                Notification_tab not = new Notification_tab();
                not.Show();
                this.Close();
            }
        }