diff --git a/ModernKeePass.Application/Application.csproj b/ModernKeePass.Application/Application.csproj
index 612419f..e23b926 100644
--- a/ModernKeePass.Application/Application.csproj
+++ b/ModernKeePass.Application/Application.csproj
@@ -95,6 +95,7 @@
+
diff --git a/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs b/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs
index bca6126..03d638e 100644
--- a/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs
+++ b/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs
@@ -51,5 +51,6 @@ namespace ModernKeePass.Application.Common.Interfaces
void DeleteHistory(string entryId, int historyIndex);
IEnumerable Search(string groupId, string text);
+ IEnumerable GetAllGroups(string groupId);
}
}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Group/Commands/AddEntry/AddEntryCommand.cs b/ModernKeePass.Application/Group/Commands/AddEntry/AddEntryCommand.cs
index 3be713a..69d036b 100644
--- a/ModernKeePass.Application/Group/Commands/AddEntry/AddEntryCommand.cs
+++ b/ModernKeePass.Application/Group/Commands/AddEntry/AddEntryCommand.cs
@@ -1,16 +1,14 @@
using System.Threading.Tasks;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Application.Entry.Models;
-using ModernKeePass.Application.Group.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Group.Commands.AddEntry
{
public class AddEntryCommand : IRequest
{
- public GroupVm ParentGroup { get; set; }
- public EntryVm Entry { get; set; }
+ public string ParentGroupId { get; set; }
+ public string EntryId { get; set; }
public class AddEntryCommandHandler : IAsyncRequestHandler
{
@@ -25,8 +23,8 @@ namespace ModernKeePass.Application.Group.Commands.AddEntry
{
if (!_database.IsOpen) throw new DatabaseClosedException();
- await _database.AddEntry(message.ParentGroup.Id, message.Entry.Id);
- message.ParentGroup.Entries.Add(message.Entry);
+ await _database.AddEntry(message.ParentGroupId, message.EntryId);
+ //message.ParentGroup.Entries.Add(message.Entry);
}
}
}
diff --git a/ModernKeePass.Application/Group/Commands/AddGroup/AddGroupCommand.cs b/ModernKeePass.Application/Group/Commands/AddGroup/AddGroupCommand.cs
index 04183a0..1bef137 100644
--- a/ModernKeePass.Application/Group/Commands/AddGroup/AddGroupCommand.cs
+++ b/ModernKeePass.Application/Group/Commands/AddGroup/AddGroupCommand.cs
@@ -1,15 +1,14 @@
using System.Threading.Tasks;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Application.Group.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Group.Commands.AddGroup
{
public class AddGroupCommand : IRequest
{
- public GroupVm ParentGroup { get; set; }
- public GroupVm Group { get; set; }
+ public string ParentGroupId { get; set; }
+ public string GroupId { get; set; }
public class AddGroupCommandHandler : IAsyncRequestHandler
{
@@ -24,8 +23,8 @@ namespace ModernKeePass.Application.Group.Commands.AddGroup
{
if (!_database.IsOpen) throw new DatabaseClosedException();
- await _database.AddGroup(message.ParentGroup.Id, message.Group.Id);
- message.ParentGroup.SubGroups.Add(message.Group);
+ await _database.AddGroup(message.ParentGroupId, message.GroupId);
+ //message.ParentGroup.SubGroups.Add(message.Group);
}
}
}
diff --git a/ModernKeePass.Application/Group/Commands/RemoveEntry/RemoveEntryCommand.cs b/ModernKeePass.Application/Group/Commands/RemoveEntry/RemoveEntryCommand.cs
index d097292..09805c8 100644
--- a/ModernKeePass.Application/Group/Commands/RemoveEntry/RemoveEntryCommand.cs
+++ b/ModernKeePass.Application/Group/Commands/RemoveEntry/RemoveEntryCommand.cs
@@ -1,16 +1,14 @@
using System.Threading.Tasks;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Application.Entry.Models;
-using ModernKeePass.Application.Group.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Group.Commands.RemoveEntry
{
public class RemoveEntryCommand : IRequest
{
- public GroupVm ParentGroup { get; set; }
- public EntryVm Entry { get; set; }
+ public string ParentGroupId { get; set; }
+ public string EntryId { get; set; }
public class RemoveEntryCommandHandler : IAsyncRequestHandler
{
@@ -25,8 +23,8 @@ namespace ModernKeePass.Application.Group.Commands.RemoveEntry
{
if (!_database.IsOpen) throw new DatabaseClosedException();
- await _database.RemoveEntry(message.ParentGroup.Id, message.Entry.Id);
- message.ParentGroup.Entries.Remove(message.Entry);
+ await _database.RemoveEntry(message.ParentGroupId, message.EntryId);
+ //message.ParentGroup.Entries.Remove(message.Entry);
}
}
}
diff --git a/ModernKeePass.Application/Group/Commands/RemoveGroup/RemoveGroupCommand.cs b/ModernKeePass.Application/Group/Commands/RemoveGroup/RemoveGroupCommand.cs
index 7fe9230..3ab54c3 100644
--- a/ModernKeePass.Application/Group/Commands/RemoveGroup/RemoveGroupCommand.cs
+++ b/ModernKeePass.Application/Group/Commands/RemoveGroup/RemoveGroupCommand.cs
@@ -1,15 +1,14 @@
using System.Threading.Tasks;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Application.Group.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Group.Commands.RemoveGroup
{
public class RemoveGroupCommand : IRequest
{
- public GroupVm ParentGroup { get; set; }
- public GroupVm Group { get; set; }
+ public string ParentGroupId { get; set; }
+ public string GroupId { get; set; }
public class RemoveGroupCommandHandler : IAsyncRequestHandler
{
@@ -24,8 +23,8 @@ namespace ModernKeePass.Application.Group.Commands.RemoveGroup
{
if (!_database.IsOpen) throw new DatabaseClosedException();
- await _database.RemoveGroup(message.ParentGroup.Id, message.Group.Id);
- message.ParentGroup.SubGroups.Remove(message.Group);
+ await _database.RemoveGroup(message.ParentGroupId, message.GroupId);
+ //message.ParentGroup.SubGroups.Remove(message.Group);
}
}
}
diff --git a/ModernKeePass.Application/Group/Models/GroupVm.cs b/ModernKeePass.Application/Group/Models/GroupVm.cs
index 829ff96..ff23eaf 100644
--- a/ModernKeePass.Application/Group/Models/GroupVm.cs
+++ b/ModernKeePass.Application/Group/Models/GroupVm.cs
@@ -5,7 +5,6 @@ using ModernKeePass.Application.Common.Mappings;
using ModernKeePass.Application.Entry.Models;
using ModernKeePass.Domain.Entities;
using ModernKeePass.Domain.Enums;
-using ModernKeePass.Domain.Interfaces;
namespace ModernKeePass.Application.Group.Models
{
diff --git a/ModernKeePass.Application/Group/Queries/GetAllGroups/GetAllGroupsQuery.cs b/ModernKeePass.Application/Group/Queries/GetAllGroups/GetAllGroupsQuery.cs
new file mode 100644
index 0000000..35ca640
--- /dev/null
+++ b/ModernKeePass.Application/Group/Queries/GetAllGroups/GetAllGroupsQuery.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Linq;
+using AutoMapper;
+using MediatR;
+using ModernKeePass.Application.Common.Interfaces;
+using ModernKeePass.Application.Group.Models;
+using ModernKeePass.Domain.Exceptions;
+
+namespace ModernKeePass.Application.Group.Queries.GetAllGroups
+{
+ public class GetAllGroupsQuery : IRequest>
+ {
+ public string GroupId { get; set; }
+
+ public class GetAllGroupsQueryHandler : IRequestHandler>
+ {
+ private readonly IDatabaseProxy _database;
+ private readonly IMapper _mapper;
+
+ public GetAllGroupsQueryHandler(IDatabaseProxy database, IMapper mapper)
+ {
+ _database = database;
+ _mapper = mapper;
+ }
+
+ public IEnumerable Handle(GetAllGroupsQuery message)
+ {
+ if (!_database.IsOpen) throw new DatabaseClosedException();
+ return _database.GetAllGroups(message.GroupId).Select(g => _mapper.Map(g));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs b/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs
index 4730988..9c26f15 100644
--- a/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs
+++ b/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs
@@ -348,6 +348,18 @@ namespace ModernKeePass.Infrastructure.KeePass
return searchResults.Select(e => _mapper.Map(e));
}
+ public IEnumerable GetAllGroups(string groupId)
+ {
+ var pwGroup = _pwDatabase.RootGroup.FindGroup(BuildIdFromString(groupId), true);
+ var groups = pwGroup.GetGroups(true).Select(g => new GroupEntity
+ {
+ Id = g.Uuid.ToHexString(),
+ Name = g.Name,
+ ParentName = g.ParentGroup?.Name
+ });
+ return groups;
+ }
+
private CompositeKey CreateCompositeKey(Credentials credentials)
{
var compositeKey = new CompositeKey();
diff --git a/ModernKeePass/ResourceDictionaries/Styles.xaml b/ModernKeePass/ResourceDictionaries/Styles.xaml
index 923a753..c2fe156 100644
--- a/ModernKeePass/ResourceDictionaries/Styles.xaml
+++ b/ModernKeePass/ResourceDictionaries/Styles.xaml
@@ -120,7 +120,7 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Visible
-
-
-
-
-
-
-
-
-
-
- Visible
-
-
-
-
-
-
-
-
-
-
-
-
- Visible
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ BorderThickness="{TemplateBinding BorderThickness}">
+
+
+
+
+
+
+
+
+
diff --git a/ModernKeePass/Strings/en-US/Resources.resw b/ModernKeePass/Strings/en-US/Resources.resw
index 98d9245..5dcf7ad 100644
--- a/ModernKeePass/Strings/en-US/Resources.resw
+++ b/ModernKeePass/Strings/en-US/Resources.resw
@@ -210,7 +210,7 @@
Create new entry
-
+
Search...
@@ -498,4 +498,10 @@
This will close the currently opened database without saving the changes.
+
+ Destination group
+
+
+ Move
+
\ No newline at end of file
diff --git a/ModernKeePass/Strings/fr-FR/Resources.resw b/ModernKeePass/Strings/fr-FR/Resources.resw
index 4ca2124..b47a40e 100644
--- a/ModernKeePass/Strings/fr-FR/Resources.resw
+++ b/ModernKeePass/Strings/fr-FR/Resources.resw
@@ -210,8 +210,8 @@
Créer une nouvelle entrée
-
- Rechercher...
+
+ Groupe de destination
Nom du nouveau groupe...
@@ -501,4 +501,10 @@
Cela va fermer la base de données ouverte sans sauvegarder les changements.
+
+ Rechercher...
+
+
+ Déplacer
+
\ No newline at end of file
diff --git a/ModernKeePass/ViewModels/EntryDetailVm.cs b/ModernKeePass/ViewModels/EntryDetailVm.cs
index f282f09..f3464a9 100644
--- a/ModernKeePass/ViewModels/EntryDetailVm.cs
+++ b/ModernKeePass/ViewModels/EntryDetailVm.cs
@@ -217,7 +217,7 @@ namespace ModernKeePass.ViewModels
public RelayCommand SaveCommand { get; }
public RelayCommand GeneratePasswordCommand { get; }
- public RelayCommand MoveCommand { get; }
+ public RelayCommand MoveCommand { get; }
public RelayCommand RestoreCommand { get; }
public RelayCommand DeleteCommand { get; }
public RelayCommand GoBackCommand { get; }
@@ -247,7 +247,7 @@ namespace ModernKeePass.ViewModels
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
- MoveCommand = new RelayCommand(async () => await Move(_parent), () => _parent != null);
+ MoveCommand = new RelayCommand(async destination => await Move(destination), destination => _parent != null && string.IsNullOrEmpty(destination) && destination != _parent.Id);
RestoreCommand = new RelayCommand(async () => await RestoreHistory());
DeleteCommand = new RelayCommand(async () => await AskForDelete());
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
@@ -319,10 +319,10 @@ namespace ModernKeePass.ViewModels
RaisePropertyChanged(nameof(IsRevealPasswordEnabled));
}
- public async Task Move(GroupVm destination)
+ public async Task Move(string destination)
{
- await _mediator.Send(new AddEntryCommand { ParentGroup = destination, Entry = SelectedItem });
- await _mediator.Send(new RemoveEntryCommand { ParentGroup = _parent, Entry = SelectedItem });
+ await _mediator.Send(new AddEntryCommand { ParentGroupId = destination, EntryId = Id });
+ await _mediator.Send(new RemoveEntryCommand { ParentGroupId = _parent.Id, EntryId = Id });
}
public async Task SetFieldValue(string fieldName, object value)
diff --git a/ModernKeePass/ViewModels/GroupDetailVm.cs b/ModernKeePass/ViewModels/GroupDetailVm.cs
index 0d34d9d..cfcef80 100644
--- a/ModernKeePass/ViewModels/GroupDetailVm.cs
+++ b/ModernKeePass/ViewModels/GroupDetailVm.cs
@@ -88,7 +88,7 @@ namespace ModernKeePass.ViewModels
public RelayCommand SaveCommand { get; }
public RelayCommand SortEntriesCommand { get; }
public RelayCommand SortGroupsCommand { get; }
- public RelayCommand MoveCommand { get; }
+ public RelayCommand MoveCommand { get; }
public RelayCommand CreateEntryCommand { get; }
public RelayCommand CreateGroupCommand { get; }
public RelayCommand DeleteCommand { get; set; }
@@ -117,10 +117,10 @@ namespace ModernKeePass.ViewModels
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
SortEntriesCommand = new RelayCommand(async () => await SortEntriesAsync(), () => IsEditMode);
SortGroupsCommand = new RelayCommand(async () => await SortGroupsAsync(), () => IsEditMode);
- MoveCommand = new RelayCommand(async () => await Move(_parent), () => IsNotRoot);
+ MoveCommand = new RelayCommand(async destination => await Move(destination), destination => IsNotRoot && !string.IsNullOrEmpty(destination) && destination != Id);
CreateEntryCommand = new RelayCommand(async () => await AddNewEntry(), () => !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(),() => IsNotRoot);
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
}
@@ -167,10 +167,10 @@ namespace ModernKeePass.ViewModels
GoToEntry(entry.Id, true);
}
- public async Task Move(GroupVm destination)
+ public async Task Move(string destinationId)
{
- await _mediator.Send(new AddGroupCommand {ParentGroup = destination, Group = _group });
- await _mediator.Send(new RemoveGroupCommand {ParentGroup = _parent, Group = _group });
+ await _mediator.Send(new AddGroupCommand {ParentGroupId = destinationId, GroupId = Id });
+ await _mediator.Send(new RemoveGroupCommand {ParentGroupId = _parent.Id, GroupId = Id });
}
public async Task> Search(string queryText)
@@ -196,7 +196,7 @@ namespace ModernKeePass.ViewModels
if (_reorderedEntry == null)
{
var entry = (EntryVm) e.NewItems[0];
- await _mediator.Send(new AddEntryCommand {Entry = entry, ParentGroup = _group});
+ await _mediator.Send(new AddEntryCommand {EntryId = entry.Id, ParentGroupId = Id});
}
else
{
diff --git a/ModernKeePass/Views/EntryDetailPage.xaml b/ModernKeePass/Views/EntryDetailPage.xaml
index 6607c78..6f70e6e 100644
--- a/ModernKeePass/Views/EntryDetailPage.xaml
+++ b/ModernKeePass/Views/EntryDetailPage.xaml
@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:viewModels="using:ModernKeePass.ViewModels"
xmlns:converters="using:ModernKeePass.Converters"
xmlns:local="using:ModernKeePass.Controls"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
@@ -431,7 +430,7 @@
-
+
diff --git a/ModernKeePass/Views/GroupDetailPage.xaml b/ModernKeePass/Views/GroupDetailPage.xaml
index 0050846..0eb2a4c 100644
--- a/ModernKeePass/Views/GroupDetailPage.xaml
+++ b/ModernKeePass/Views/GroupDetailPage.xaml
@@ -270,7 +270,7 @@
-
+
diff --git a/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs b/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs
index 9e77ecc..7843b35 100644
--- a/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs
+++ b/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
+using System.Windows.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
-using GalaSoft.MvvmLight.Command;
using ModernKeePass.Application.Common.Interfaces;
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
@@ -125,15 +125,15 @@ namespace ModernKeePass.Views.UserControls
typeof(HamburgerMenuUserControl),
new PropertyMetadata(false, (o, args) => { }));
- public RelayCommand ActionButtonCommand
+ public ICommand ActionButtonCommand
{
- get { return (RelayCommand)GetValue(ActionButtonCommandProperty); }
+ get { return (ICommand)GetValue(ActionButtonCommandProperty); }
set { SetValue(ActionButtonCommandProperty, value); }
}
public static readonly DependencyProperty ActionButtonCommandProperty =
DependencyProperty.Register(
nameof(ActionButtonCommand),
- typeof(RelayCommand),
+ typeof(ICommand),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
diff --git a/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml b/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml
index 5437a98..991d762 100644
--- a/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml
+++ b/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml
@@ -16,7 +16,7 @@
-
+
@@ -49,12 +49,29 @@
-