mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
SavePage uses nav service
This commit is contained in:
@@ -160,7 +160,6 @@ namespace ModernKeePass
|
|||||||
|
|
||||||
var launchActivatedEventArgs = e as LaunchActivatedEventArgs;
|
var launchActivatedEventArgs = e as LaunchActivatedEventArgs;
|
||||||
if (launchActivatedEventArgs != null && rootFrame.Content == null)
|
if (launchActivatedEventArgs != null && rootFrame.Content == null)
|
||||||
//rootFrame.Navigate(typeof(MainPage), launchActivatedEventArgs.Arguments);
|
|
||||||
_navigation.NavigateTo(Constants.Navigation.MainPage, launchActivatedEventArgs.Arguments);
|
_navigation.NavigateTo(Constants.Navigation.MainPage, launchActivatedEventArgs.Arguments);
|
||||||
|
|
||||||
// Ensure the current window is active
|
// Ensure the current window is active
|
||||||
@@ -251,12 +250,10 @@ namespace ModernKeePass
|
|||||||
Name = file.DisplayName,
|
Name = file.DisplayName,
|
||||||
Path = file.Path
|
Path = file.Path
|
||||||
};
|
};
|
||||||
//rootFrame.Navigate(typeof(MainPage), fileInfo);
|
|
||||||
_navigation.NavigateTo(Constants.Navigation.MainPage, fileInfo);
|
_navigation.NavigateTo(Constants.Navigation.MainPage, fileInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//rootFrame.Navigate(typeof(MainPage));
|
|
||||||
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.Storage;
|
using Windows.Storage;
|
||||||
using Windows.Storage.AccessCache;
|
using Windows.Storage.AccessCache;
|
||||||
using Windows.UI.Xaml.Controls;
|
using GalaSoft.MvvmLight.Views;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ModernKeePass.Application.Database.Commands.CloseDatabase;
|
using ModernKeePass.Application.Database.Commands.CloseDatabase;
|
||||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||||
using ModernKeePass.Views;
|
using ModernKeePass.Common;
|
||||||
|
using RelayCommand = GalaSoft.MvvmLight.Command.RelayCommand;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
@@ -18,15 +18,16 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public RelayCommand SaveCommand { get; }
|
public RelayCommand SaveCommand { get; }
|
||||||
public RelayCommand CloseCommand { get; }
|
public RelayCommand CloseCommand { get; }
|
||||||
public Frame Frame { get; set; }
|
|
||||||
|
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
|
private readonly INavigationService _navigation;
|
||||||
|
|
||||||
public SaveVm() : this(App.Services.GetRequiredService<IMediator>()) { }
|
public SaveVm() : this(App.Services.GetRequiredService<IMediator>(), App.Services.GetRequiredService<INavigationService>()) { }
|
||||||
|
|
||||||
public SaveVm(IMediator mediator)
|
public SaveVm(IMediator mediator, INavigationService navigation)
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
|
_navigation = navigation;
|
||||||
SaveCommand = new RelayCommand(async () => await Save(), () => IsSaveEnabled);
|
SaveCommand = new RelayCommand(async () => await Save(), () => IsSaveEnabled);
|
||||||
CloseCommand = new RelayCommand(async () => await Close());
|
CloseCommand = new RelayCommand(async () => await Close());
|
||||||
}
|
}
|
||||||
@@ -35,20 +36,20 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
await _mediator.Send(new SaveDatabaseCommand());
|
await _mediator.Send(new SaveDatabaseCommand());
|
||||||
if (close) await _mediator.Send(new CloseDatabaseCommand());
|
if (close) await _mediator.Send(new CloseDatabaseCommand());
|
||||||
Frame.Navigate(typeof(MainPage));
|
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Save(StorageFile file)
|
public async Task Save(StorageFile file)
|
||||||
{
|
{
|
||||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||||
await _mediator.Send(new SaveDatabaseCommand { FilePath = token });
|
await _mediator.Send(new SaveDatabaseCommand { FilePath = token });
|
||||||
Frame.Navigate(typeof(MainPage));
|
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Close()
|
public async Task Close()
|
||||||
{
|
{
|
||||||
await _mediator.Send(new CloseDatabaseCommand());
|
await _mediator.Send(new CloseDatabaseCommand());
|
||||||
Frame.Navigate(typeof(MainPage));
|
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,8 +4,6 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
|
||||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
|
||||||
x:Class="ModernKeePass.Views.SaveDatabasePage"
|
x:Class="ModernKeePass.Views.SaveDatabasePage"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.DataContext>
|
<Page.DataContext>
|
||||||
|
@@ -2,8 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Windows.Storage.Pickers;
|
using Windows.Storage.Pickers;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Navigation;
|
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
@@ -20,12 +18,6 @@ namespace ModernKeePass.Views
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnNavigatedTo(e);
|
|
||||||
Model.Frame = e.Parameter as Frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void SaveAsButton_OnClick(object sender, RoutedEventArgs e)
|
private async void SaveAsButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user