mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
All VMs use viewmodellocator
This commit is contained in:
@@ -9,7 +9,6 @@ using GalaSoft.MvvmLight;
|
|||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using GalaSoft.MvvmLight.Views;
|
using GalaSoft.MvvmLight.Views;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||||
using ModernKeePass.Application.Database.Models;
|
using ModernKeePass.Application.Database.Models;
|
||||||
@@ -58,7 +57,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<GroupVm> BreadCrumb => new List<GroupVm> { _parent };
|
public IEnumerable<GroupVm> BreadCrumb => new List<GroupVm> { _parent };
|
||||||
public ObservableCollection<EntryVm> History { get; }
|
public ObservableCollection<EntryVm> History { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the Entry is current or from history
|
/// Determines if the Entry is current or from history
|
||||||
@@ -230,7 +229,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
private readonly IResourceProxy _resource;
|
private readonly IResourceProxy _resource;
|
||||||
private readonly IDialogService _dialog;
|
private readonly IDialogService _dialog;
|
||||||
private readonly INotificationService _notification;
|
private readonly INotificationService _notification;
|
||||||
private readonly GroupVm _parent;
|
private GroupVm _parent;
|
||||||
private EntryVm _selectedItem;
|
private EntryVm _selectedItem;
|
||||||
private int _selectedIndex;
|
private int _selectedIndex;
|
||||||
private bool _isEditMode;
|
private bool _isEditMode;
|
||||||
@@ -238,30 +237,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
private double _passwordLength = 25;
|
private double _passwordLength = 25;
|
||||||
private bool _isDirty;
|
private bool _isDirty;
|
||||||
|
|
||||||
public EntryDetailVm() { }
|
public EntryDetailVm(IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog, INotificationService notification)
|
||||||
|
|
||||||
internal EntryDetailVm(string entryId) : this(entryId,
|
|
||||||
App.Services.GetRequiredService<IMediator>(),
|
|
||||||
App.Services.GetRequiredService<INavigationService>(),
|
|
||||||
App.Services.GetRequiredService<IResourceProxy>(),
|
|
||||||
App.Services.GetRequiredService<IDialogService>(),
|
|
||||||
App.Services.GetRequiredService<INotificationService>()) { }
|
|
||||||
|
|
||||||
public EntryDetailVm(string entryId, IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog, INotificationService notification)
|
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
_resource = resource;
|
_resource = resource;
|
||||||
_dialog = dialog;
|
_dialog = dialog;
|
||||||
_notification = notification;
|
_notification = notification;
|
||||||
SelectedItem = _mediator.Send(new GetEntryQuery { Id = entryId }).GetAwaiter().GetResult();
|
|
||||||
_parent = _mediator.Send(new GetGroupQuery { Id = SelectedItem.ParentGroupId }).GetAwaiter().GetResult();
|
|
||||||
History = new ObservableCollection<EntryVm> { SelectedItem };
|
|
||||||
foreach (var entry in SelectedItem.History.Skip(1))
|
|
||||||
{
|
|
||||||
History.Add(entry);
|
|
||||||
}
|
|
||||||
SelectedIndex = 0;
|
|
||||||
|
|
||||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||||
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
|
||||||
@@ -271,6 +253,18 @@ namespace ModernKeePass.ViewModels
|
|||||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task Initialize(string entryId)
|
||||||
|
{
|
||||||
|
SelectedItem = await _mediator.Send(new GetEntryQuery { Id = entryId });
|
||||||
|
_parent = await _mediator.Send(new GetGroupQuery { Id = SelectedItem.ParentGroupId });
|
||||||
|
History = new ObservableCollection<EntryVm> { SelectedItem };
|
||||||
|
foreach (var entry in SelectedItem.History.Skip(1))
|
||||||
|
{
|
||||||
|
History.Add(entry);
|
||||||
|
}
|
||||||
|
SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task AskForDelete()
|
private async Task AskForDelete()
|
||||||
{
|
{
|
||||||
if (IsCurrentEntry)
|
if (IsCurrentEntry)
|
||||||
|
@@ -9,7 +9,6 @@ using GalaSoft.MvvmLight;
|
|||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
using GalaSoft.MvvmLight.Views;
|
using GalaSoft.MvvmLight.Views;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||||
using ModernKeePass.Application.Database.Models;
|
using ModernKeePass.Application.Database.Models;
|
||||||
@@ -36,9 +35,9 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
public class GroupDetailVm : ObservableObject
|
public class GroupDetailVm : ObservableObject
|
||||||
{
|
{
|
||||||
public ObservableCollection<EntryVm> Entries { get; }
|
public ObservableCollection<EntryVm> Entries { get; private set; }
|
||||||
|
|
||||||
public ObservableCollection<GroupVm> Groups { get; }
|
public ObservableCollection<GroupVm> Groups { get; private set; }
|
||||||
|
|
||||||
public bool IsNotRoot => Database.RootGroupId != _group.Id;
|
public bool IsNotRoot => Database.RootGroupId != _group.Id;
|
||||||
|
|
||||||
@@ -84,7 +83,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public bool IsInRecycleBin => _parent != null && _parent.Id == Database.RecycleBinId;
|
public bool IsInRecycleBin => _parent != null && _parent.Id == Database.RecycleBinId;
|
||||||
|
|
||||||
public IEnumerable<GroupVm> BreadCrumb { get; }
|
public IEnumerable<GroupVm> BreadCrumb { get; private set; }
|
||||||
|
|
||||||
public RelayCommand SaveCommand { get; }
|
public RelayCommand SaveCommand { get; }
|
||||||
public RelayCommand SortEntriesCommand { get; }
|
public RelayCommand SortEntriesCommand { get; }
|
||||||
@@ -102,34 +101,18 @@ namespace ModernKeePass.ViewModels
|
|||||||
private readonly INavigationService _navigation;
|
private readonly INavigationService _navigation;
|
||||||
private readonly IDialogService _dialog;
|
private readonly IDialogService _dialog;
|
||||||
private readonly INotificationService _notification;
|
private readonly INotificationService _notification;
|
||||||
private readonly GroupVm _group;
|
private GroupVm _group;
|
||||||
private readonly GroupVm _parent;
|
private GroupVm _parent;
|
||||||
private bool _isEditMode;
|
private bool _isEditMode;
|
||||||
private EntryVm _reorderedEntry;
|
private EntryVm _reorderedEntry;
|
||||||
|
|
||||||
public GroupDetailVm() {}
|
public GroupDetailVm(IMediator mediator, IResourceProxy resource, INavigationService navigation, IDialogService dialog, INotificationService notification)
|
||||||
|
|
||||||
internal GroupDetailVm(string groupId) : this(groupId,
|
|
||||||
App.Services.GetRequiredService<IMediator>(),
|
|
||||||
App.Services.GetRequiredService<IResourceProxy>(),
|
|
||||||
App.Services.GetRequiredService<INavigationService>(),
|
|
||||||
App.Services.GetRequiredService<IDialogService>(),
|
|
||||||
App.Services.GetRequiredService<INotificationService>())
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public GroupDetailVm(string groupId, IMediator mediator, IResourceProxy resource, INavigationService navigation, IDialogService dialog, INotificationService notification)
|
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
_resource = resource;
|
_resource = resource;
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
_dialog = dialog;
|
_dialog = dialog;
|
||||||
_notification = notification;
|
_notification = notification;
|
||||||
_group = _mediator.Send(new GetGroupQuery { Id = groupId }).GetAwaiter().GetResult();
|
|
||||||
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
|
||||||
{
|
|
||||||
_parent = _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId }).GetAwaiter().GetResult();
|
|
||||||
BreadCrumb = new List<GroupVm> {_parent};
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||||
SortEntriesCommand = new RelayCommand(async () => await SortEntriesAsync(), () => IsEditMode);
|
SortEntriesCommand = new RelayCommand(async () => await SortEntriesAsync(), () => IsEditMode);
|
||||||
@@ -139,32 +122,22 @@ namespace ModernKeePass.ViewModels
|
|||||||
CreateGroupCommand = new RelayCommand(async () => await AddNewGroup(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
CreateGroupCommand = new RelayCommand(async () => await AddNewGroup(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
||||||
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
||||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Initialize(string groupId)
|
||||||
|
{
|
||||||
|
_group = await _mediator.Send(new GetGroupQuery { Id = groupId });
|
||||||
|
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
||||||
|
{
|
||||||
|
_parent = await _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId });
|
||||||
|
BreadCrumb = new List<GroupVm> { _parent };
|
||||||
|
}
|
||||||
|
|
||||||
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
||||||
Entries.CollectionChanged += Entries_CollectionChanged;
|
Entries.CollectionChanged += Entries_CollectionChanged;
|
||||||
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
|
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AskForDelete()
|
|
||||||
{
|
|
||||||
if (IsRecycleOnDelete)
|
|
||||||
{
|
|
||||||
await Delete();
|
|
||||||
_notification.Show(_resource.GetResourceValue("GroupRecyclingConfirmation"), _resource.GetResourceValue("GroupRecycled"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _dialog.ShowMessage(_resource.GetResourceValue("GroupDeletingConfirmation"), _resource.GetResourceValue("EntityDeleteTitle"),
|
|
||||||
_resource.GetResourceValue("EntityDeleteActionButton"),
|
|
||||||
_resource.GetResourceValue("EntityDeleteCancelButton"),
|
|
||||||
async isOk =>
|
|
||||||
{
|
|
||||||
if (isOk) await Delete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task AddNewGroup(string name = "")
|
public async Task AddNewGroup(string name = "")
|
||||||
{
|
{
|
||||||
var group = await _mediator.Send(new CreateGroupCommand {Name = name, ParentGroup = _group});
|
var group = await _mediator.Send(new CreateGroupCommand {Name = name, ParentGroup = _group});
|
||||||
@@ -239,6 +212,25 @@ namespace ModernKeePass.ViewModels
|
|||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task AskForDelete()
|
||||||
|
{
|
||||||
|
if (IsRecycleOnDelete)
|
||||||
|
{
|
||||||
|
await Delete();
|
||||||
|
_notification.Show(_resource.GetResourceValue("GroupRecyclingConfirmation"), _resource.GetResourceValue("GroupRecycled"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _dialog.ShowMessage(_resource.GetResourceValue("GroupDeletingConfirmation"), _resource.GetResourceValue("EntityDeleteTitle"),
|
||||||
|
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||||
|
_resource.GetResourceValue("EntityDeleteCancelButton"),
|
||||||
|
async isOk =>
|
||||||
|
{
|
||||||
|
if (isOk) await Delete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task Delete()
|
private async Task Delete()
|
||||||
{
|
{
|
||||||
await _mediator.Send(new DeleteGroupCommand
|
await _mediator.Send(new DeleteGroupCommand
|
||||||
|
@@ -5,7 +5,6 @@ using Windows.UI.Xaml.Controls;
|
|||||||
using GalaSoft.MvvmLight;
|
using GalaSoft.MvvmLight;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Messages;
|
using Messages;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||||
using ModernKeePass.Domain.Dtos;
|
using ModernKeePass.Domain.Dtos;
|
||||||
@@ -61,30 +60,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainVm() {}
|
|
||||||
|
|
||||||
internal MainVm(Frame referenceFrame, Frame destinationFrame, FileInfo databaseFile = null) : this(
|
|
||||||
referenceFrame,
|
|
||||||
destinationFrame,
|
|
||||||
App.Services.GetRequiredService<IMediator>(),
|
|
||||||
App.Services.GetRequiredService<IRecentProxy>(),
|
|
||||||
App.Services.GetRequiredService<IResourceProxy>(),
|
|
||||||
App.Services.GetRequiredService<IDialogService>(),
|
|
||||||
App.Services.GetRequiredService<INotificationService>(),
|
|
||||||
App.Services.GetRequiredService<INavigationService>(),
|
|
||||||
databaseFile)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public MainVm(
|
public MainVm(
|
||||||
Frame referenceFrame,
|
|
||||||
Frame destinationFrame,
|
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IRecentProxy recent,
|
IRecentProxy recent,
|
||||||
IResourceProxy resource,
|
IResourceProxy resource,
|
||||||
IDialogService dialog,
|
IDialogService dialog,
|
||||||
INotificationService notification,
|
INotificationService notification,
|
||||||
INavigationService navigation,
|
INavigationService navigation)
|
||||||
FileInfo databaseFile = null)
|
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
_recent = recent;
|
_recent = recent;
|
||||||
@@ -93,15 +75,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
_notification = notification;
|
_notification = notification;
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
|
|
||||||
BuildMainMenuItems(referenceFrame, destinationFrame, databaseFile);
|
|
||||||
|
|
||||||
MessengerInstance.Register<DatabaseOpenedMessage>(this, NavigateToPage);
|
MessengerInstance.Register<DatabaseOpenedMessage>(this, NavigateToPage);
|
||||||
MessengerInstance.Register<DatabaseAlreadyOpenedMessage>(this, async message => await DisplaySaveConfirmation(message));
|
MessengerInstance.Register<DatabaseAlreadyOpenedMessage>(this, async message => await DisplaySaveConfirmation(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildMainMenuItems(Frame referenceFrame, Frame destinationFrame, FileInfo databaseFile)
|
public async Task Initialize(Frame referenceFrame, Frame destinationFrame, FileInfo databaseFile = null)
|
||||||
{
|
{
|
||||||
var database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||||
var mainMenuItems = new ObservableCollection<MainMenuItemVm>
|
var mainMenuItems = new ObservableCollection<MainMenuItemVm>
|
||||||
{
|
{
|
||||||
new MainMenuItemVm
|
new MainMenuItemVm
|
||||||
|
@@ -12,7 +12,8 @@
|
|||||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||||
x:Class="ModernKeePass.Views.EntryDetailPage"
|
x:Class="ModernKeePass.Views.EntryDetailPage"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
SizeChanged="EntryDetailPage_OnSizeChanged">
|
SizeChanged="EntryDetailPage_OnSizeChanged"
|
||||||
|
DataContext="{Binding Source={StaticResource Locator}, Path=Entry}">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />
|
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />
|
||||||
@@ -369,9 +370,6 @@
|
|||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
|
||||||
<viewModels:EntryDetailVm />
|
|
||||||
</Page.DataContext>
|
|
||||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
<Grid.ChildrenTransitions>
|
<Grid.ChildrenTransitions>
|
||||||
<TransitionCollection>
|
<TransitionCollection>
|
||||||
|
@@ -27,7 +27,8 @@ namespace ModernKeePass.Views
|
|||||||
var args = e.Parameter as NavigationItem;
|
var args = e.Parameter as NavigationItem;
|
||||||
if (args != null)
|
if (args != null)
|
||||||
{
|
{
|
||||||
DataContext = new EntryDetailVm(args.Id) { IsEditMode = args.IsNew };
|
await Model.Initialize(args.Id);
|
||||||
|
Model.IsEditMode = args.IsNew;
|
||||||
if (args.IsNew) await Model.GeneratePassword();
|
if (args.IsNew) await Model.GeneratePassword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,25 +3,21 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
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:converters="using:ModernKeePass.Converters"
|
xmlns:converters="using:ModernKeePass.Converters"
|
||||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||||
xmlns:actions="using:ModernKeePass.Actions"
|
xmlns:actions="using:ModernKeePass.Actions"
|
||||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||||
x:Name="PageRoot"
|
|
||||||
x:Class="ModernKeePass.Views.GroupDetailPage"
|
x:Class="ModernKeePass.Views.GroupDetailPage"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
SizeChanged="GroupDetailPage_OnSizeChanged">
|
SizeChanged="GroupDetailPage_OnSizeChanged"
|
||||||
|
DataContext="{Binding Source={StaticResource Locator}, Path=Group}">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
|
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
|
||||||
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
|
||||||
<viewModels:GroupDetailVm />
|
|
||||||
</Page.DataContext>
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Resources>
|
<Grid.Resources>
|
||||||
<CollectionViewSource
|
<CollectionViewSource
|
||||||
|
@@ -7,7 +7,6 @@ using Windows.UI.Xaml.Controls;
|
|||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
using GalaSoft.MvvmLight.Views;
|
using GalaSoft.MvvmLight.Views;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
|
||||||
using ModernKeePass.Application.Entry.Models;
|
using ModernKeePass.Application.Entry.Models;
|
||||||
using ModernKeePass.Common;
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Models;
|
using ModernKeePass.Models;
|
||||||
@@ -23,26 +22,27 @@ namespace ModernKeePass.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class GroupDetailPage
|
public sealed partial class GroupDetailPage
|
||||||
{
|
{
|
||||||
private readonly IResourceProxy _resource;
|
|
||||||
private readonly INavigationService _navigation;
|
private readonly INavigationService _navigation;
|
||||||
|
|
||||||
public GroupDetailVm Model => (GroupDetailVm)DataContext;
|
public GroupDetailVm Model => (GroupDetailVm)DataContext;
|
||||||
|
|
||||||
public GroupDetailPage(): this (App.Services.GetRequiredService<IResourceProxy>(), App.Services.GetRequiredService<INavigationService>()) { }
|
public GroupDetailPage(): this (App.Services.GetRequiredService<INavigationService>()) { }
|
||||||
public GroupDetailPage(IResourceProxy resource, INavigationService navigation)
|
public GroupDetailPage(INavigationService navigation)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_resource = resource;
|
|
||||||
_navigation = navigation;
|
_navigation = navigation;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region NavigationHelper registration
|
#region NavigationHelper registration
|
||||||
|
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
var navigationItem = e.Parameter as NavigationItem;
|
var navigationItem = e.Parameter as NavigationItem;
|
||||||
if (navigationItem != null)
|
if (navigationItem != null)
|
||||||
DataContext = new GroupDetailVm(navigationItem.Id) { IsEditMode = navigationItem.IsNew };
|
{
|
||||||
|
await Model.Initialize(navigationItem.Id);
|
||||||
|
Model.IsEditMode = navigationItem.IsNew;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@@ -3,12 +3,12 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
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:controls="using:ModernKeePass.Controls"
|
xmlns:controls="using:ModernKeePass.Controls"
|
||||||
xmlns:basePages="using:ModernKeePass.Views.BasePages"
|
xmlns:basePages="using:ModernKeePass.Views.BasePages"
|
||||||
x:Class="ModernKeePass.Views.MainPage"
|
x:Class="ModernKeePass.Views.MainPage"
|
||||||
x:Name="PageRoot"
|
x:Name="PageRoot"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d"
|
||||||
|
DataContext="{Binding Source={StaticResource Locator}, Path=Main}">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<CollectionViewSource
|
<CollectionViewSource
|
||||||
x:Name="MenuItemsSource"
|
x:Name="MenuItemsSource"
|
||||||
@@ -19,9 +19,6 @@
|
|||||||
<Page.Background>
|
<Page.Background>
|
||||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||||
</Page.Background>
|
</Page.Background>
|
||||||
<Page.DataContext>
|
|
||||||
<viewModels:MainVm />
|
|
||||||
</Page.DataContext>
|
|
||||||
|
|
||||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||||
<Grid.ChildrenTransitions>
|
<Grid.ChildrenTransitions>
|
||||||
|
@@ -37,11 +37,11 @@ namespace ModernKeePass.Views
|
|||||||
else selectedItem.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter);
|
else selectedItem.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnNavigatedTo(e);
|
base.OnNavigatedTo(e);
|
||||||
var file = e.Parameter as FileInfo;
|
var file = e.Parameter as FileInfo;
|
||||||
DataContext = new MainVm(Frame, MenuFrame, file);
|
await Model.Initialize(Frame, MenuFrame, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,11 +11,9 @@ using Windows.UI.Xaml;
|
|||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
using UnhandledExceptionEventArgs = Windows.UI.Xaml.UnhandledExceptionEventArgs;
|
using UnhandledExceptionEventArgs = Windows.UI.Xaml.UnhandledExceptionEventArgs;
|
||||||
using Autofac;
|
|
||||||
using Microsoft.AppCenter;
|
using Microsoft.AppCenter;
|
||||||
using Microsoft.AppCenter.Analytics;
|
using Microsoft.AppCenter.Analytics;
|
||||||
using ModernKeePass.Common;
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Composition;
|
|
||||||
using ModernKeePass.Domain.Dtos;
|
using ModernKeePass.Domain.Dtos;
|
||||||
using ModernKeePass.Domain.Exceptions;
|
using ModernKeePass.Domain.Exceptions;
|
||||||
using ModernKeePass.Domain.Interfaces;
|
using ModernKeePass.Domain.Interfaces;
|
||||||
@@ -30,10 +28,6 @@ namespace ModernKeePass
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
sealed partial class App
|
sealed partial class App
|
||||||
{
|
{
|
||||||
private readonly IDatabaseService _databaseService;
|
|
||||||
|
|
||||||
public static IContainer Container { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the singleton application object. This is the first line of authored code
|
/// Initializes the singleton application object. This is the first line of authored code
|
||||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||||
@@ -48,12 +42,7 @@ namespace ModernKeePass
|
|||||||
UnhandledException += OnUnhandledException;
|
UnhandledException += OnUnhandledException;
|
||||||
|
|
||||||
// Setup DI
|
// Setup DI
|
||||||
var builder = new ContainerBuilder();
|
|
||||||
builder.RegisterModule<SharedCompositionRoot>();
|
|
||||||
builder.RegisterModule<UwpCompositionRoot>();
|
|
||||||
Container = builder.Build();
|
|
||||||
|
|
||||||
_databaseService = Container.Resolve<IDatabaseService>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event Handlers
|
#region Event Handlers
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
<AppxBundlePlatforms>neutral</AppxBundlePlatforms>
|
<AppxBundlePlatforms>neutral</AppxBundlePlatforms>
|
||||||
<AppxBundle>Always</AppxBundle>
|
<AppxBundle>Always</AppxBundle>
|
||||||
<RuntimeIdentifiers>win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -432,23 +434,6 @@
|
|||||||
<Content Include="Assets\Wide310x150Logo.scale-180.png" />
|
<Content Include="Assets\Wide310x150Logo.scale-180.png" />
|
||||||
<Content Include="Assets\Wide310x150Logo.scale-80.png" />
|
<Content Include="Assets\Wide310x150Logo.scale-80.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.AppCenter.Analytics">
|
|
||||||
<Version>3.0.0</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
|
||||||
<Version>6.2.9</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
|
|
||||||
<Version>6.0.0</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.UI.Xaml">
|
|
||||||
<Version>2.3.200213001</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
|
|
||||||
<Version>2.0.1</Version>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ModernKeePass.Application\Application.csproj">
|
<ProjectReference Include="..\ModernKeePass.Application\Application.csproj">
|
||||||
<Project>{42353562-5e43-459c-8e3e-2f21e575261d}</Project>
|
<Project>{42353562-5e43-459c-8e3e-2f21e575261d}</Project>
|
||||||
|
@@ -63,10 +63,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
SimpleIoc.Default.Register<SettingsSecurityVm>();
|
SimpleIoc.Default.Register<SettingsSecurityVm>();
|
||||||
SimpleIoc.Default.Register<OpenDatabaseControlVm>();
|
SimpleIoc.Default.Register<OpenDatabaseControlVm>();
|
||||||
SimpleIoc.Default.Register<SetCredentialsVm>();
|
SimpleIoc.Default.Register<SetCredentialsVm>();
|
||||||
|
SimpleIoc.Default.Register<MainVm>();
|
||||||
SimpleIoc.Default.Register<NewVm>();
|
SimpleIoc.Default.Register<NewVm>();
|
||||||
SimpleIoc.Default.Register<OpenVm>();
|
SimpleIoc.Default.Register<OpenVm>();
|
||||||
SimpleIoc.Default.Register<RecentVm>();
|
SimpleIoc.Default.Register<RecentVm>();
|
||||||
SimpleIoc.Default.Register<SaveVm>();
|
SimpleIoc.Default.Register<SaveVm>();
|
||||||
|
SimpleIoc.Default.Register<GroupDetailVm>();
|
||||||
|
SimpleIoc.Default.Register<EntryDetailVm>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainVm Main => ServiceLocator.Current.GetInstance<MainVm>(Guid.NewGuid().ToString());
|
public MainVm Main => ServiceLocator.Current.GetInstance<MainVm>(Guid.NewGuid().ToString());
|
||||||
@@ -81,6 +84,8 @@ namespace ModernKeePass.ViewModels
|
|||||||
public OpenVm Open => ServiceLocator.Current.GetInstance<OpenVm>(Guid.NewGuid().ToString());
|
public OpenVm Open => ServiceLocator.Current.GetInstance<OpenVm>(Guid.NewGuid().ToString());
|
||||||
public RecentVm Recent => ServiceLocator.Current.GetInstance<RecentVm>(Guid.NewGuid().ToString());
|
public RecentVm Recent => ServiceLocator.Current.GetInstance<RecentVm>(Guid.NewGuid().ToString());
|
||||||
public SaveVm Save => ServiceLocator.Current.GetInstance<SaveVm>(Guid.NewGuid().ToString());
|
public SaveVm Save => ServiceLocator.Current.GetInstance<SaveVm>(Guid.NewGuid().ToString());
|
||||||
|
public GroupDetailVm Group => ServiceLocator.Current.GetInstance<GroupDetailVm>(Guid.NewGuid().ToString());
|
||||||
|
public EntryDetailVm Entry => ServiceLocator.Current.GetInstance<EntryDetailVm>(Guid.NewGuid().ToString());
|
||||||
|
|
||||||
public static void Cleanup()
|
public static void Cleanup()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user