public MainVM(INav nav, IVmFactory _vmf, IAuth _auth) { Nav = nav; AuthService = _auth; NavCommand = new NavCommand(nav, _vmf); NavCommand.Execute(ViewType.Login); }
public MainWindowViewModel() { NaviCommand = new NavCommand(dosomething); //The DisplayMessage will be passed as an action DisplayMessageCommand = new MessageCommand(DisplayMessage); this.RunCode = new SimpleCommand(this); HiButtonCommand = new RelayCommand(ShowMessage, param => this.canExecute); toggleExecuteCommand = new RelayCommand(ChangeCanExecute); }
public SectionViewModel(IMvxNavigationService navigationService, GardianAppContext appContext, NavCommand navCommand, ShareCommand shareCommand) { this.appContext = appContext; //Command GoToNewsDetailsCommand = new GoToNewsDetailsCommand(navigationService); NavMenuTriggerCommand = new MvxCommand(NavPanelTrigger); NavCommand = navCommand; ShareCommand = shareCommand; PageTitle = appContext.Settings.PageSettings; ProgressRingIsActive = true; ProgressRingVisibility = true; }
public DetailsViewModel(IMvxNavigationService navigationService, GardianAppContext appContext, NavCommand navCommand, ShareCommand shareCommand) { _navigationService = navigationService; this.appContext = appContext; //Commands NavMenuTriggerCommand = new MvxCommand(NavPanelTrigger); NavCommand = navCommand; ShareCommand = shareCommand; //Ring ProgressRingIsActive = true; ProgressRingVisibility = true; PageTitle = "Details"; }
public HomeViewModel(IMvxNavigationService navigationService, GardianAppContext appContext, NavCommand navCommand, ShareCommand shareCommand) { this.appContext = appContext; appContext.Settings = new AppSettings("All News", string.Empty); appContext.SaveSettings(appContext.Settings); //Command GoToNewsDetailsCommand = new GoToNewsDetailsCommand(navigationService); NavMenuTriggerCommand = new MvxCommand(NavPanelTrigger); NavCommand = navCommand; ShareCommand = shareCommand; PageTitle = "All News"; IsPaneOpen = true; NewsCollection = new ObservableCollection <StoryHeader>(); ProgressRingIsActive = true; ProgressRingVisibility = true; Initialize(); }
// handle keyboard navigation (tabs and gamepad) private void HamburgerMenu_KeyDown(object sender, KeyRoutedEventArgs e) { var currentItem = FocusManager.GetFocusedElement() as FrameworkElement; var lastItem = LoadedNavButtons.FirstOrDefault(x => x.HamburgerButtonInfo == (SecondaryButtons.LastOrDefault(a => a != Selected) ?? PrimaryButtons.LastOrDefault(a => a != Selected))); var focus = new Func <FocusNavigationDirection, bool>(d => { if (d == FocusNavigationDirection.Next) { return(FocusManager.TryMoveFocus(d)); } else if (d == FocusNavigationDirection.Previous) { return(FocusManager.TryMoveFocus(d)); } else { var control = FocusManager.FindNextFocusableElement(d) as Control; return(control?.Focus(FocusState.Programmatic) ?? false); } }); var escape = new Func <bool>(() => { if (DisplayMode == SplitViewDisplayMode.CompactOverlay || DisplayMode == SplitViewDisplayMode.Overlay) { IsOpen = false; } if (Equals(ShellSplitView.PanePlacement, SplitViewPanePlacement.Left)) { ShellSplitView.Content.RenderTransform = new TranslateTransform { X = 48 + ShellSplitView.OpenPaneLength }; focus(FocusNavigationDirection.Right); ShellSplitView.Content.RenderTransform = null; } else { ShellSplitView.Content.RenderTransform = new TranslateTransform { X = -48 - ShellSplitView.OpenPaneLength }; focus(FocusNavigationDirection.Left); ShellSplitView.Content.RenderTransform = null; } return(true); }); var previous = new Func <bool>(() => { if (Equals(currentItem, HamburgerButton)) { return(true); } else if (focus(FocusNavigationDirection.Previous) || focus(FocusNavigationDirection.Up)) { return(true); } else { return(escape()); } }); var next = new Func <bool>(() => { if (Equals(currentItem, HamburgerButton)) { return(focus(FocusNavigationDirection.Down)); } else if (focus(FocusNavigationDirection.Next) || focus(FocusNavigationDirection.Down)) { return(true); } else { return(escape()); } }); if (IsFullScreen) { return; } switch (e.Key) { case VirtualKey.Up: case VirtualKey.GamepadDPadUp: if (!(e.Handled = previous())) { Debugger.Break(); } break; case VirtualKey.Down: case VirtualKey.GamepadDPadDown: if (!(e.Handled = next())) { Debugger.Break(); } break; case VirtualKey.Right: case VirtualKey.GamepadDPadRight: if (SecondaryButtonContainer.Items.Contains(currentItem?.DataContext) && SecondaryButtonOrientation == Orientation.Horizontal) { if (Equals(lastItem.FrameworkElement, currentItem)) { if (!(e.Handled = escape())) { Debugger.Break(); } } else { if (!(e.Handled = next())) { Debugger.Break(); } } } else { if (!(e.Handled = escape())) { Debugger.Break(); } } break; case VirtualKey.Left: case VirtualKey.GamepadDPadLeft: if (SecondaryButtonContainer.Items.Contains(currentItem?.DataContext) && SecondaryButtonOrientation == Orientation.Horizontal) { if (Equals(lastItem.FrameworkElement, currentItem)) { if (!(e.Handled = escape())) { Debugger.Break(); } } else { if (!(e.Handled = previous())) { Debugger.Break(); } } } else { if (!(e.Handled = escape())) { Debugger.Break(); } } break; case VirtualKey.Space: case VirtualKey.Enter: case VirtualKey.GamepadA: if (currentItem != null) { var info = new InfoElement(currentItem); var hamburgerButtonInfo = info.HamburgerButtonInfo; if (hamburgerButtonInfo != null) { NavCommand.Execute(hamburgerButtonInfo); } } break; case VirtualKey.Escape: case VirtualKey.GamepadB: if (!(e.Handled = escape())) { Debugger.Break(); } break; } }