mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Fix navigation issue
Applied some syntax style
This commit is contained in:
@@ -85,7 +85,7 @@ namespace ModernKeePass.Views.BasePages
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Preserves state associated with this page in case the application is suspended or the
|
/// Preserves state associated with this page in case the application is suspended or the
|
||||||
/// page is discarded from the navigation cache. Values must conform to the serialization
|
/// page is discarded from the navigation cache. Values must conform to the serialization
|
||||||
/// requirements of <see cref="Common.SuspensionManager.SessionState"/>.
|
/// requirements of <see cref="SuspensionManager.SessionState"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender">The source of the event; typically <see cref="Common.NavigationHelper"/></param>
|
/// <param name="sender">The source of the event; typically <see cref="Common.NavigationHelper"/></param>
|
||||||
/// <param name="e">Event data that provides an empty dictionary to be populated with
|
/// <param name="e">Event data that provides an empty dictionary to be populated with
|
||||||
|
@@ -27,8 +27,14 @@ namespace ModernKeePass.Views
|
|||||||
base.ListView_SelectionChanged(sender, e);
|
base.ListView_SelectionChanged(sender, e);
|
||||||
|
|
||||||
var selectedItem = Model.SelectedItem as MainMenuItemVm;
|
var selectedItem = Model.SelectedItem as MainMenuItemVm;
|
||||||
if (selectedItem == null) MenuFrame.Navigate(typeof(WelcomePage));
|
if (selectedItem == null)
|
||||||
else selectedItem.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter);
|
{
|
||||||
|
MenuFrame.Navigate(typeof(WelcomePage));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectedItem.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||||
@@ -36,15 +42,21 @@ namespace ModernKeePass.Views
|
|||||||
base.OnNavigatedTo(e);
|
base.OnNavigatedTo(e);
|
||||||
FileInfo file;
|
FileInfo file;
|
||||||
if (e.NavigationMode == NavigationMode.Back)
|
if (e.NavigationMode == NavigationMode.Back)
|
||||||
|
{
|
||||||
file = null;
|
file = null;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
file = e.Parameter as FileInfo;
|
file = e.Parameter as FileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
await Model.Initialize(Frame, MenuFrame, file);
|
await Model.Initialize(Frame, MenuFrame, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
Model.Cleanup();
|
Model.Cleanup();
|
||||||
|
base.OnNavigatedFrom(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -120,15 +120,10 @@ namespace ModernKeePass.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public RelayCommand GoBackCommand
|
public RelayCommand GoBackCommand
|
||||||
{
|
{
|
||||||
get
|
get { return _goBackCommand ?? (_goBackCommand = new RelayCommand(GoBack, CanGoBack)); }
|
||||||
{
|
set { _goBackCommand = value; }
|
||||||
return _goBackCommand ?? (_goBackCommand = new RelayCommand(GoBack, CanGoBack));
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_goBackCommand = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="RelayCommand"/> used for navigating to the most recent item in
|
/// <see cref="RelayCommand"/> used for navigating to the most recent item in
|
||||||
/// the forward navigation history, if a Frame manages its own navigation history.
|
/// the forward navigation history, if a Frame manages its own navigation history.
|
||||||
@@ -150,6 +145,7 @@ namespace ModernKeePass.Common
|
|||||||
{
|
{
|
||||||
return Frame != null && Frame.CanGoBack;
|
return Frame != null && Frame.CanGoBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Virtual method used by the <see cref="GoForwardCommand"/> property
|
/// Virtual method used by the <see cref="GoForwardCommand"/> property
|
||||||
/// to determine if the <see cref="Frame"/> can go forward.
|
/// to determine if the <see cref="Frame"/> can go forward.
|
||||||
@@ -169,15 +165,22 @@ namespace ModernKeePass.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void GoBack()
|
public virtual void GoBack()
|
||||||
{
|
{
|
||||||
if (Frame != null && Frame.CanGoBack) Frame.GoBack();
|
if (Frame != null && Frame.CanGoBack)
|
||||||
|
{
|
||||||
|
Frame.GoBack();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Virtual method used by the <see cref="GoForwardCommand"/> property
|
/// Virtual method used by the <see cref="GoForwardCommand"/> property
|
||||||
/// to invoke the <see cref="Windows.UI.Xaml.Controls.Frame.GoForward"/> method.
|
/// to invoke the <see cref="Windows.UI.Xaml.Controls.Frame.GoForward"/> method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void GoForward()
|
public virtual void GoForward()
|
||||||
{
|
{
|
||||||
if (Frame != null && Frame.CanGoForward) Frame.GoForward();
|
if (Frame != null && Frame.CanGoForward)
|
||||||
|
{
|
||||||
|
Frame.GoForward();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WINDOWS_PHONE_APP
|
#if WINDOWS_PHONE_APP
|
||||||
@@ -253,7 +256,10 @@ namespace ModernKeePass.Common
|
|||||||
|
|
||||||
// Ignore button chords with the left, right, and middle buttons
|
// Ignore button chords with the left, right, and middle buttons
|
||||||
if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed ||
|
if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed ||
|
||||||
properties.IsMiddleButtonPressed) return;
|
properties.IsMiddleButtonPressed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If back or forward are pressed (but not both) navigate appropriately
|
// If back or forward are pressed (but not both) navigate appropriately
|
||||||
var backPressed = properties.IsXButton1Pressed;
|
var backPressed = properties.IsXButton1Pressed;
|
||||||
@@ -261,8 +267,15 @@ namespace ModernKeePass.Common
|
|||||||
if (backPressed ^ forwardPressed)
|
if (backPressed ^ forwardPressed)
|
||||||
{
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
if (backPressed) GoBackCommand.Execute(null);
|
if (backPressed)
|
||||||
if (forwardPressed) GoForwardCommand.Execute(null);
|
{
|
||||||
|
GoBackCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forwardPressed)
|
||||||
|
{
|
||||||
|
GoForwardCommand.Execute(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -279,6 +292,7 @@ namespace ModernKeePass.Common
|
|||||||
/// state provided when recreating a page from a prior session.
|
/// state provided when recreating a page from a prior session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event LoadStateEventHandler LoadState;
|
public event LoadStateEventHandler LoadState;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register this event on the current page to preserve
|
/// Register this event on the current page to preserve
|
||||||
/// state associated with the current page in case the
|
/// state associated with the current page in case the
|
||||||
@@ -345,6 +359,7 @@ namespace ModernKeePass.Common
|
|||||||
/// Represents the method that will handle the <see cref="NavigationHelper.LoadState"/>event
|
/// Represents the method that will handle the <see cref="NavigationHelper.LoadState"/>event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate void LoadStateEventHandler(object sender, LoadStateEventArgs e);
|
public delegate void LoadStateEventHandler(object sender, LoadStateEventArgs e);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the method that will handle the <see cref="NavigationHelper.SaveState"/>event
|
/// Represents the method that will handle the <see cref="NavigationHelper.SaveState"/>event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -360,6 +375,7 @@ namespace ModernKeePass.Common
|
|||||||
/// when this page was initially requested.
|
/// when this page was initially requested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object NavigationParameter { get; private set; }
|
public object NavigationParameter { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dictionary of state preserved by this page during an earlier
|
/// A dictionary of state preserved by this page during an earlier
|
||||||
/// session. This will be null the first time a page is visited.
|
/// session. This will be null the first time a page is visited.
|
||||||
@@ -383,6 +399,7 @@ namespace ModernKeePass.Common
|
|||||||
PageState = pageState;
|
PageState = pageState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class used to hold the event data required when a page attempts to save state.
|
/// Class used to hold the event data required when a page attempts to save state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -38,7 +38,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public async Task Initialize(GroupVm group)
|
public async Task Initialize(GroupVm group)
|
||||||
{
|
{
|
||||||
if (group == null) return;
|
if (group == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GoBackCommand.RaiseCanExecuteChanged();
|
GoBackCommand.RaiseCanExecuteChanged();
|
||||||
ParentGroupName = group.Title;
|
ParentGroupName = group.Title;
|
||||||
ParentGroupIcon = group.Icon;
|
ParentGroupIcon = group.Icon;
|
||||||
@@ -54,7 +58,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
private void GoTo(int index)
|
private void GoTo(int index)
|
||||||
{
|
{
|
||||||
if (BreadcrumbItems.Count == 0) return;
|
if (BreadcrumbItems.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var breadcrumb = BreadcrumbItems[index];
|
var breadcrumb = BreadcrumbItems[index];
|
||||||
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem {Id = breadcrumb.Path});
|
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem {Id = breadcrumb.Path});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user