示例#1
0
        public MainPage()
        {
            this.InitializeComponent();

            // Set up the UI
            VisualStateManager.GoToState(this, "HideQuichSeachResults", false);

            // Set ourselves as the backend action listener
            App.BaconMan.SetBackendActionListner(this);

            // Set the title bar color
            ApplicationView.GetForCurrentView().TitleBar.BackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.InactiveBackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = Color.FromArgb(255, 255, 255, 255);
            ApplicationView.GetForCurrentView().TitleBar.InactiveForegroundColor = Color.FromArgb(255, 255, 255, 255);
            ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Color.FromArgb(255, 255, 255, 255);
            ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveForegroundColor = Color.FromArgb(255, 255, 255, 255);

            // Create the starting panel
            WelcomePanel panel = new WelcomePanel();

            // Create the panel manager
            m_panelManager = new PanelManager(this, (IPanel)panel);
            ui_contentRoot.Children.Add(m_panelManager);
            m_panelManager.OnGoBack += PanelManager_OnGoBack;

            // Add transparency to the account header, this will make it darker
            Color accentColor = (ui_accountHeaderGrid.Background as SolidColorBrush).Color;

            accentColor.A = 200;
            ui_accountHeaderGrid.Background = new SolidColorBrush(accentColor);

            // Add some transparency to the subreddit header also.
            accentColor   = (ui_accountHeaderGrid.Background as SolidColorBrush).Color;
            accentColor.A = 137;
            ui_trendingSubredditsHeader.Background = new SolidColorBrush(accentColor);

            // Add some transparency to the search header also.
            accentColor   = (ui_accountHeaderGrid.Background as SolidColorBrush).Color;
            accentColor.A = 75;
            ui_searchHeader.Background = new SolidColorBrush(accentColor);

            // Sub to callbacks
            App.BaconMan.SubredditMan.OnSubredditsUpdated += SubredditMan_OnSubredditUpdate;
            App.BaconMan.UserMan.OnUserUpdated            += UserMan_OnUserUpdated;

            // Sub to loaded
            Loaded += MainPage_Loaded;
            App.BaconMan.OnResuming += App_OnResuming;

            // Set the subreddit list
            ui_subredditList.ItemsSource = m_subreddits;

            // Setup the keyboard shortcut helper and sub.
            m_keyboardShortcutHepler = new KeyboardShortcutHelper();
            m_keyboardShortcutHepler.OnQuickSearchActivation += KeyboardShortcutHepler_OnQuickSearchActivation;
        }
示例#2
0
        public MainPage()
        {
            this.InitializeComponent();

            // Set up the UI
            VisualStateManager.GoToState(this, "HideQuichSeachResults", false);

            // Set ourselves as the backend action listener
            App.BaconMan.SetBackendActionListener(this);

            // Set the title bar color
            ApplicationView.GetForCurrentView().TitleBar.BackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.InactiveBackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Color.FromArgb(255, 51, 51, 51);
            ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = Color.FromArgb(255, 255, 255, 255);
            ApplicationView.GetForCurrentView().TitleBar.InactiveForegroundColor = Color.FromArgb(255, 255, 255, 255);
            ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Color.FromArgb(255, 255, 255, 255);
            ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveForegroundColor = Color.FromArgb(255, 255, 255, 255);

            // Create the starting panel
            WelcomePanel panel = new WelcomePanel();

            // Create the panel manager
            m_panelManager = new PanelManager(this, (IPanel)panel);
            ui_contentRoot.Children.Add(m_panelManager);
            App.BaconMan.OnBackButton += BaconMan_OnBackButton;

            // Sub to callbacks
            App.BaconMan.SubredditMan.OnSubredditsUpdated += SubredditMan_OnSubredditUpdate;
            App.BaconMan.UserMan.OnUserUpdated            += UserMan_OnUserUpdated;

            // Sub to loaded
            Loaded += MainPage_Loaded;
            App.BaconMan.OnResuming += App_OnResuming;

            // Set the subreddit list
            ui_subredditList.ItemsSource = m_subreddits;

            // Setup the keyboard shortcut helper and sub.
            m_keyboardShortcutHepler = new KeyboardShortcutHelper();
            m_keyboardShortcutHepler.OnQuickSearchActivation += KeyboardShortcutHepler_OnQuickSearchActivation;
            m_keyboardShortcutHepler.OnGoBackActivation      += KeyboardShortcutHepler_OnGoBackActivation;

            m_panelManager.OnNavigationComplete += PanelManager_OnNavigationComplete;

            // Sub to the memory report
            App.BaconMan.MemoryMan.OnMemoryReport += MemoryMan_OnMemoryReport;
        }
示例#3
0
 protected override bool ProcessKeyPreview(ref Message m)
 {
     KeyboardShortcutHelper.ProcessKeyPreview(ref m, ModifierKeys);
     return(base.ProcessKeyPreview(ref m));
 }
示例#4
0
        private async void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
        {
            if (!xpoWebView.IsWebAppLoaded)
            {
                return;
            }

            if (e.EventType == CoreAcceleratorKeyEventType.KeyDown || e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown)
            {
                // We won't process the event if the currently focused element is WebView,
                // as the web app can handle keyboard shortcuts itself.
                if (FocusManager.GetFocusedElement().GetType() == typeof(WebView))
                {
                    return;
                }

                var shiftState   = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Shift);
                var shiftPressed = (shiftState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                var ctrlState   = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control);
                var ctrlPressed = (ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                var altState   = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Menu);
                var altPressed = (altState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                logger.Info(e.VirtualKey);
                var isHandled = await KeyboardShortcutHelper.KeyDown(e.VirtualKey, shiftPressed, ctrlPressed, altPressed, xpoWebView.Controller, nowPlaying);

                if (isHandled == KeyboardShortcutHelper.KeyDownProcessResult.AskJs)
                {
                    logger.Info("Sending it to js...");
                    int charCode    = (int)e.VirtualKey;
                    var handledByJs = await xpoWebView.Controller.OnKeyDown(charCode, shiftPressed, ctrlPressed, altPressed);

                    if (handledByJs)
                    {
                        if (nowPlaying.IsOpen)
                        {
                            if (nowPlaying.ViewMode == NowPlayingView.NowPlayingViewMode.CompactOverlay)
                            {
                                CloseCompactOverlay();
                            }
                            else
                            {
                                CloseNowPlaying();
                            }
                        }
                    }
                }
                else if (isHandled == KeyboardShortcutHelper.KeyDownProcessResult.GoBack)
                {
                    if (nowPlaying.IsOpen)
                    {
                        if (nowPlaying.ViewMode == NowPlayingView.NowPlayingViewMode.CompactOverlay)
                        {
                            CloseCompactOverlay();
                        }
                        else if (ApplicationView.GetForCurrentView().IsFullScreenMode)
                        {
                            nowPlaying.ToggleFullscreen();
                        }
                        else
                        {
                            CloseNowPlaying();
                        }
                    }
                }
            }
        }