public static Common.HandledEventArgs RaiseBackRequested() { var args = new Common.HandledEventArgs(); BackRequested?.Invoke(null, args); return(args); }
private void TestForNavigateRequested(KeyDownEventArgs e) { if ((e.VirtualKey == VirtualKey.GoBack) || (e.VirtualKey == VirtualKey.NavigationLeft) || (e.VirtualKey == VirtualKey.GamepadMenu) || (e.VirtualKey == VirtualKey.GamepadLeftShoulder) || (e.OnlyAlt && e.VirtualKey == VirtualKey.Back) || (e.OnlyAlt && e.VirtualKey == VirtualKey.Left)) { Debug.WriteLine($"{nameof(GestureService)}.{nameof(BackRequested)}"); BackRequested?.Invoke(null, EventArgs.Empty); } else if ((e.VirtualKey == VirtualKey.GoForward) || (e.VirtualKey == VirtualKey.NavigationRight) || (e.VirtualKey == VirtualKey.GamepadRightShoulder) || (e.OnlyAlt && e.VirtualKey == VirtualKey.Right)) { Debug.WriteLine($"{nameof(GestureService)}.{nameof(ForwardRequested)}"); ForwardRequested?.Invoke(null, EventArgs.Empty); } else if ((e.VirtualKey == VirtualKey.Refresh) || (e.VirtualKey == VirtualKey.F5)) { Debug.WriteLine($"{nameof(GestureService)}.{nameof(RefreshRequested)}"); RefreshRequested?.Invoke(null, EventArgs.Empty); } }
private void OnNativeBackRequested(object sender, Windows.UI.Core.BackRequestedEventArgs e) { var args = new BackRequestedEventArgs(); BackRequested?.Invoke(this, args); e.Handled = args.Handled; }
private void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs e) { var properties = e.CurrentPoint.Properties; // Ignore button chords with the left, right, and middle buttons if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || properties.IsMiddleButtonPressed) { return; } // If back or forward are pressed (but not both) navigate appropriately bool backPressed = properties.IsXButton1Pressed; bool forwardPressed = properties.IsXButton2Pressed; if (backPressed ^ forwardPressed) { e.Handled = true; if (backPressed) { BackRequested?.Invoke(this, EventArgs.Empty); } //if (forwardPressed) this.GoForwardCommand.Execute(null); } }
public GestureService(IBackButtonService backService, IKeyboardService keyService) { Two.BackService = backService as IBackButtonService2; Two.BackService.BackRequested += (s, e) => { BackRequested2?.Invoke(s, e); if (AllowBackRequested) { BackRequested?.Invoke(s, e); } }; Two.BackService.ForwardRequested += (s, e) => { ForwardRequested2?.Invoke(s, e); if (AllowForwardRequested) { ForwardRequested?.Invoke(s, e); } }; Two.KeyService = keyService as IKeyboardService2; Two.KeyService.AfterSearchGesture += (s, e) => AfterSearchGesture?.Invoke(s, e); Two.KeyService.AfterMenuGesture += (s, e) => AfterMenuGesture?.Invoke(s, e); Two.KeyService.AfterKeyDown += (s, e) => AfterKeyDown?.Invoke(s, e); }
public void RaiseBackRequested(HandledEventArgs args) { BackRequested?.Invoke(this, args); if (BackButtonHandling == BootStrapper.BackButton.Attach && !args.Handled && (args.Handled = Frame.BackStackDepth > 0)) { GoBack(); } }
/// <summary> /// Initializes a new instance of the <see cref="NavigationView"/> class. /// </summary> /// <param name="mainScheduler">The main scheduler to scheduler UI tasks on.</param> /// <param name="backgroundScheduler">The background scheduler.</param> /// <param name="viewLocator">The view locator which will find views associated with view models.</param> public NavigationView(IScheduler mainScheduler, IScheduler backgroundScheduler, IViewLocator viewLocator) { InitializeComponent(); _logger = this.Log(); _backgroundScheduler = backgroundScheduler; _mainScheduler = mainScheduler; _viewLocator = viewLocator; _mirroredPageStack = new Stack <IViewModel?>(); _mirroredModalStack = new Stack <IViewModel?>(); backButton.Visibility = Visibility.Collapsed; PagePopped = Observable .FromEvent <NavigatedEventHandler, NavigationEventArgs>( handler => { return((sender, e) => handler(e)); }, x => mainFrame.Navigated += x, x => mainFrame.Navigated -= x) .Do(args => { if (mainFrame.CanGoBack) { IsBackButtonVisible = true; } else { IsBackButtonVisible = false; } }) .Where(ep => ep.NavigationMode == NavigationMode.Back) .Select(ep => { var view = ep.Content as IViewFor; if (view == null) { _logger.Debug($"The view ({ep.Content.GetType()}) does not implement IViewFor<>. Cannot set ViewModel from a back navigation."); } else { view.ViewModel = _mirroredPageStack.Peek(); } // Since view stack doesn't contain instances (only types), we have to store the latest viewmodel and return it on a back nav. // ep.Content contains an instance of the new view, but it may have just been created and its ViewModel property will be null. // But we want the view that was just removed. We need to send the old view's viewmodel to IViewStackService so that the ViewModel can be removed from the stack. return(_lastPoppedViewModel); }) .WhereNotNull(); BackRequested.Subscribe(); }
private void Toggle_Click(object sender, RoutedEventArgs e) { if (TogglePaneButton.IsChecked == true) { BackRequested?.Invoke(this, null); } else { IsPaneOpen = !IsPaneOpen; } }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior that navigates to previous app /// in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested event and setting the /// Handled property of the BackRequestedEventArgs to true. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnBackRequested(object sender, Windows.UI.Core.BackRequestedEventArgs e) { BackRequested?.Invoke(this, e); if (!e.Handled) { if (this.RootFrame.CanGoBack) { RootFrame.GoBack(); e.Handled = true; } } }
public void RaiseBackRequested(HandledEventArgs args) { if (BackRequested != null) { BackRequested.Invoke(this, args); } if (!args.Handled && (args.Handled = this.Frame.BackStackDepth > 0)) { GoBack(); } }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior that navigates to previous app /// in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested event and setting the /// Handled property of the BackRequestedEventArgs to true. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnBackRequested() { var args = new HandledEventArgs(); BackRequested?.Invoke(this, args); if (!args.Handled) { NavigationService.GoBack(); args.Handled = true; } }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior /// that navigates to previous app in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested /// event and setting the Handled property of the BackRequestedEventArgs to true. /// </summary> private void RaiseBackRequested(Windows.System.VirtualKey key, ref bool handled) { DebugWrite(); var args = new HandledEventArgs(); BackRequested?.Invoke(null, args); if (handled = args.Handled) { return; } var popups = VisualTreeHelper.GetOpenPopups(Window.Current); foreach (var popup in popups) { if (popup.Child is INavigablePage page) { page.OnBackRequested(args); if (handled = args.Handled) { return; } } else if (popup.Child is ContentDialog dialog) { dialog.Hide(); return; } else if (key == Windows.System.VirtualKey.Escape) { handled = args.Handled = true; return; } } foreach (var frame in WindowContext.GetForCurrentView().NavigationServices.Select(x => x.FrameFacade).Reverse()) { frame.RaiseBackRequested(args); if (handled = args.Handled) { return; } } if (NavigationService?.CanGoBack ?? false) { NavigationService?.GoBack(); } }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior that navigates to previous app /// in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested event and setting the /// Handled property of the BackRequestedEventArgs to true. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RaiseBackRequested() { var args = new HandledEventArgs(); BackRequested?.Invoke(this, args); if (!args.Handled) { // default to first window NavigationService.GoBack(); args.Handled = true; } }
private void OnBackRequested(object sender, BackRequestedEventArgs e) { // Fire the event - allows pages/Viewmodels to override/augment default back navigation behavior BackRequested?.Invoke(this, e); if (!e.Handled) { Frame frame = Window.Current.Content as Frame; if (frame.CanGoBack) { frame.GoBack(); e.Handled = true; } } }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior that navigates to previous app /// in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested event and setting the /// Handled property of the BackRequestedEventArgs to true. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnBackRequested(object sender, BackRequestedEventArgs e) { BackRequested?.Invoke(this, e); if (e.Handled) { return; } if (!RootFrame.CanGoBack) { return; } RootFrame.GoBack(); e.Handled = true; }
private void OnBackRequested(object sender, BackRequestedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; BackRequested?.Invoke(sender, e); if (!e.Handled) { if (rootFrame != null && rootFrame.CanGoBack) { e.Handled = true; rootFrame.GoBack(); } } }
public void RaiseBackRequested(HandledEventArgs args) { if (BackRequested == null) { args.Handled = this.Frame.BackStackDepth > 0; if (args.Handled) { this.GoBack(); } } else { BackRequested?.Invoke(this, args); } }
HandledEventArgs IBackButtonService2.RaiseBackRequested() { var cancelEventArgs = new CancelEventArgs(); BeforeBackRequested?.Invoke(null, cancelEventArgs); if (cancelEventArgs.Cancel) { return(new HandledEventArgs { Handled = true }); } var handledEventArgs = new HandledEventArgs(); BackRequested?.Invoke(null, handledEventArgs); return(handledEventArgs); }
public Common.HandledEventArgs RaiseBackRequested() { var cancelEventArgs = new CancelEventArgs(); BeforeBackRequested?.Invoke(null, cancelEventArgs); if (cancelEventArgs.Cancel) { return(new Common.HandledEventArgs { Handled = true }); } var handledEventArgs = new Common.HandledEventArgs(); BackRequested?.Invoke(null, handledEventArgs); return(handledEventArgs); }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior /// that navigates to previous app in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested /// event and setting the Handled property of the BackRequestedEventArgs to true. /// </summary> private void RaiseBackRequested(ref bool handled) { var args = new HandledEventArgs(); BackRequested?.Invoke(null, args); if (handled = args.Handled) { return; } foreach (var frame in WindowWrapper.Current().NavigationServices.Select(x => x.FrameFacade).Reverse()) { frame.RaiseBackRequested(args); if (handled = args.Handled) { return; } } NavigationService.GoBack(); }
private void TestForNavigateRequested(PointerEventArgs e, PointerPointProperties properties) { // If back or foward are pressed (but not both) var backPressed = properties.IsXButton1Pressed; var forwardPressed = properties.IsXButton2Pressed; if (backPressed ^ forwardPressed) { e.Handled = true; if (backPressed) { Debug.WriteLine($"{nameof(GestureService)}.{nameof(BackRequested)}"); BackRequested?.Invoke(null, EventArgs.Empty); } else if (forwardPressed) { Debug.WriteLine($"{nameof(GestureService)}.{nameof(ForwardRequested)}"); ForwardRequested?.Invoke(null, EventArgs.Empty); } } }
private void RaiseBackRequested(ref bool handled) { DebugWrite(); var args = new HandledEventArgs(); BackRequested?.Invoke(null, args); if (handled = args.Handled) { return; } foreach (var navigationService in WindowWrapper.Current().NavigationServices.Select(x => x).Reverse()) { navigationService.RaiseBackRequested(args); if (handled = args.Handled) { return; } } NavigationService.GoBack(); handled = true; }
public void Back() { var currentEntry = HistoryStack.FirstOrDefault(h => h.Current); int currentIndex = HistoryStack.ToList().IndexOf(currentEntry); var validNavigationStack = HistoryStack // Transform to list so we don't affect the original stack ?.ToList(); // Find the index of the current address in the valid history items int currentIndex_validStack = validNavigationStack.FindLastIndex(h => h.Current); var newEntry = validNavigationStack.ElementAtOrDefault(currentIndex_validStack + 1); if (newEntry is null) { // We can't go back, the UI should reflect that CanGoBackChanged?.Invoke(false); // And the code shouldn't try. return; } foreach (var h in HistoryStack) { h.Current = false; } // This is the entry we're navigating to, so it should be marked as current HistoryStack.First(h => h.VisitedAt == newEntry.VisitedAt).Current = true; int newHistoryItemIndexOnStack = HistoryStack.ToList().FindIndex(h => h.VisitedAt == newEntry.VisitedAt); if (validNavigationStack != null) { CanGoBackChanged?.Invoke(newHistoryItemIndexOnStack + 1 < HistoryStack.Count()); CanGoForwardChanged?.Invoke(true); BackRequested?.Invoke(newEntry); } }
private void RaiseBackRequested(ref bool handled) { DebugWrite(); var args = new HandledEventArgs(); BackRequested?.Invoke(null, args); if (handled = args.Handled) { return; } foreach (var navigationService in Services.NavigationService.NavigationService.Instances.Select(x => x).Reverse()) { navigationService.RaiseBackRequested(args); if (handled = args.Handled) { return; } } handled = (NavigationService.FrameFacade.BackStack.Count > 0); NavigationService.GoBack(); }
/// <summary> /// Navigates to the most recent item in back navigation history, if a Frame manages its own /// navigation history. /// </summary> /// <param name="navigationType">The type of navigation attempt</param> /// <returns>true if the navigation attempt was successful; otherwise, false</returns> public async Task <bool> GoBack(NavigationType navigationType) { var eventArgs = new CauldronBackRequestedEventArgs(); BackRequested?.Invoke(this, eventArgs); if (eventArgs.IsHandled) { return(true); } if (this.BackStack.Count < 2) { return(false); } var stackEntry = this.BackStack[this.BackStack.Count - 2]; this.ForwardStack.Add(this.BackStack[this.BackStack.Count - 1]); this.BackStack.RemoveAt(this.BackStack.Count - 1); this.BackStack.RemoveAt(this.BackStack.Count - 1); return(await this.Navigate(stackEntry.ViewModelType, stackEntry.Parameters, NavigationMode.Back, navigationType)); }
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e) { var virtualKey = e.VirtualKey; // Only investigate further when Left, Right, or the dedicated Previous or Next keys // are pressed if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || e.EventType == CoreAcceleratorKeyEventType.KeyDown) && (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || (int)virtualKey == 166 || (int)virtualKey == 167)) { var coreWindow = Window.Current.CoreWindow; var downState = CoreVirtualKeyStates.Down; bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState; bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState; bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState; bool noModifiers = !menuKey && !controlKey && !shiftKey; bool onlyAlt = menuKey && !controlKey && !shiftKey; if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt)) { // When the previous key or Alt+Left are pressed navigate back e.Handled = true; BackRequested?.Invoke(this, EventArgs.Empty); } //else if (((int)virtualKey == 167 && noModifiers) || // (virtualKey == VirtualKey.Right && onlyAlt)) //{ // // When the next key or Alt+Right are pressed navigate forward // e.Handled = true; // this.GoForwardCommand.Execute(null); //} } }
internal void RaiseBackRequested(HandledEventArgs args) => BackRequested?.Invoke(this, args);
private void OnNavigationViewBackButtonClick(object sender, RoutedEventArgs e) { BackRequested?.Invoke(this, new NavigationViewBackRequestedEventArgs()); }
public void RaiseBackRequested(HandledEventArgs args) { BackRequested?.Invoke(this, args); // for backwards compat FrameFacade.RaiseBackRequested(args); }
void INavigationServiceInternal.RaiseBackRequested(HandledEventArgs args) { BackRequested?.Invoke(this, args); }