mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Create DB works correctly
Sample data moved to application Tests updated (still not working - splat) WIP
This commit is contained in:
@@ -34,6 +34,26 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||||
<None Include="project.json" />
|
<None Include="project.json" />
|
||||||
|
@@ -20,7 +20,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
|||||||
|
|
||||||
Task Open(byte[] file, Credentials credentials);
|
Task Open(byte[] file, Credentials credentials);
|
||||||
Task ReOpen(byte[] file);
|
Task ReOpen(byte[] file);
|
||||||
Task Create(byte[] file, Credentials credentials, DatabaseVersion version = DatabaseVersion.V2);
|
Task Create(Credentials credentials, string name, DatabaseVersion version = DatabaseVersion.V2);
|
||||||
Task<byte[]> SaveDatabase();
|
Task<byte[]> SaveDatabase();
|
||||||
Task<byte[]> SaveDatabase(byte[] newFileContents);
|
Task<byte[]> SaveDatabase(byte[] newFileContents);
|
||||||
void UpdateCredentials(Credentials credentials);
|
void UpdateCredentials(Credentials credentials);
|
||||||
@@ -35,7 +35,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
|||||||
Task RemoveGroup(string parentGroupId, string groupId);
|
Task RemoveGroup(string parentGroupId, string groupId);
|
||||||
void DeleteEntity(string entityId);
|
void DeleteEntity(string entityId);
|
||||||
EntryEntity CreateEntry(string parentGroupId);
|
EntryEntity CreateEntry(string parentGroupId);
|
||||||
GroupEntity CreateGroup(string parentGroupId, string nameId, bool isRecycleBin = false);
|
GroupEntity CreateGroup(string parentGroupId, string name, bool isRecycleBin = false);
|
||||||
void SortEntries(string groupId);
|
void SortEntries(string groupId);
|
||||||
void SortSubGroups(string groupId);
|
void SortSubGroups(string groupId);
|
||||||
EntryEntity GetEntry(string id);
|
EntryEntity GetEntry(string id);
|
||||||
|
@@ -7,7 +7,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
|||||||
public interface IRecentProxy
|
public interface IRecentProxy
|
||||||
{
|
{
|
||||||
int EntryCount { get; }
|
int EntryCount { get; }
|
||||||
Task<FileInfo> Get(string token);
|
Task<FileInfo> Get(string token, bool updateAccessTime = false);
|
||||||
Task<IEnumerable<FileInfo>> GetAll();
|
Task<IEnumerable<FileInfo>> GetAll();
|
||||||
Task Add(FileInfo recentItem);
|
Task Add(FileInfo recentItem);
|
||||||
void ClearAll();
|
void ClearAll();
|
||||||
|
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Domain.Dtos;
|
using ModernKeePass.Domain.Dtos;
|
||||||
using ModernKeePass.Domain.Exceptions;
|
using ModernKeePass.Domain.Exceptions;
|
||||||
|
using ModernKeePass.Domain.Enums;
|
||||||
|
|
||||||
namespace ModernKeePass.Application.Database.Commands.CreateDatabase
|
namespace ModernKeePass.Application.Database.Commands.CreateDatabase
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,8 @@ namespace ModernKeePass.Application.Database.Commands.CreateDatabase
|
|||||||
public string FilePath { get; set; }
|
public string FilePath { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string KeyFilePath { get; set; }
|
public string KeyFilePath { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public bool CreateSampleData { get; set; }
|
||||||
|
|
||||||
public class CreateDatabaseCommandHandler : IAsyncRequestHandler<CreateDatabaseCommand>
|
public class CreateDatabaseCommandHandler : IAsyncRequestHandler<CreateDatabaseCommand>
|
||||||
{
|
{
|
||||||
@@ -27,16 +30,33 @@ namespace ModernKeePass.Application.Database.Commands.CreateDatabase
|
|||||||
{
|
{
|
||||||
if (_database.IsOpen) throw new DatabaseOpenException();
|
if (_database.IsOpen) throw new DatabaseOpenException();
|
||||||
|
|
||||||
var file = await _file.OpenBinaryFile(message.FilePath);
|
await _database.Create(new Credentials
|
||||||
await _database.Create(file,
|
|
||||||
new Credentials
|
|
||||||
{
|
{
|
||||||
KeyFileContents = !string.IsNullOrEmpty(message.KeyFilePath) ? await _file.OpenBinaryFile(message.KeyFilePath) : null,
|
KeyFileContents = !string.IsNullOrEmpty(message.KeyFilePath) ? await _file.OpenBinaryFile(message.KeyFilePath) : null,
|
||||||
Password = message.Password
|
Password = message.Password
|
||||||
});
|
}, message.Name);
|
||||||
_database.FileAccessToken = message.FilePath;
|
_database.FileAccessToken = message.FilePath;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (message.CreateSampleData)
|
||||||
|
{
|
||||||
|
var bankingGroup = _database.CreateGroup(_database.RootGroupId, "Banking");
|
||||||
|
var emailGroup = _database.CreateGroup(_database.RootGroupId, "Email");
|
||||||
|
var internetGroup = _database.CreateGroup(_database.RootGroupId, "Internet");
|
||||||
|
|
||||||
|
var sample1 = _database.CreateEntry(_database.RootGroupId);
|
||||||
|
_database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry" );
|
||||||
|
_database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username" );
|
||||||
|
_database.UpdateEntry(sample1.Id, EntryFieldName.Password, "Password" );
|
||||||
|
_database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/" );
|
||||||
|
_database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample" );
|
||||||
|
|
||||||
|
var sample2 = _database.CreateEntry(_database.RootGroupId);
|
||||||
|
_database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2" );
|
||||||
|
_database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321" );
|
||||||
|
_database.UpdateEntry(sample2.Id, EntryFieldName.Password, "12345" );
|
||||||
|
_database.UpdateEntry(sample2.Id, EntryFieldName.Url, "https://keepass.info/help/kb/testform.html" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -34,6 +34,22 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||||
<None Include="project.json" />
|
<None Include="project.json" />
|
||||||
|
@@ -34,6 +34,25 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||||
<None Include="Libs\Windows.winmd" />
|
<None Include="Libs\Windows.winmd" />
|
||||||
|
@@ -31,6 +31,8 @@ namespace ModernKeePass.Infrastructure.KeePass
|
|||||||
public bool IsOpen => (_pwDatabase?.IsOpen).GetValueOrDefault();
|
public bool IsOpen => (_pwDatabase?.IsOpen).GetValueOrDefault();
|
||||||
public string Name => _pwDatabase?.Name;
|
public string Name => _pwDatabase?.Name;
|
||||||
public string RootGroupId => _pwDatabase?.RootGroup.Uuid.ToHexString();
|
public string RootGroupId => _pwDatabase?.RootGroup.Uuid.ToHexString();
|
||||||
|
|
||||||
|
// TODO: find a correct place for this
|
||||||
public string FileAccessToken { get; set; }
|
public string FileAccessToken { get; set; }
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
@@ -111,16 +113,18 @@ namespace ModernKeePass.Infrastructure.KeePass
|
|||||||
await Open(file, _credentials);
|
await Open(file, _credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Create(byte[] file, Credentials credentials, DatabaseVersion version = DatabaseVersion.V2)
|
public async Task Create(Credentials credentials, string name, DatabaseVersion version = DatabaseVersion.V2)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
var compositeKey = CreateCompositeKey(credentials);
|
var compositeKey = CreateCompositeKey(credentials);
|
||||||
var ioConnection = IOConnectionInfo.FromByteArray(file);
|
var ioConnection = IOConnectionInfo.FromByteArray(new byte[] {});
|
||||||
|
|
||||||
_pwDatabase.New(ioConnection, compositeKey);
|
_pwDatabase.New(ioConnection, compositeKey);
|
||||||
|
_pwDatabase.Name = name;
|
||||||
|
_pwDatabase.RootGroup.Name = name;
|
||||||
|
|
||||||
switch (version)
|
switch (version)
|
||||||
{
|
{
|
||||||
|
@@ -14,10 +14,9 @@ namespace ModernKeePass.Infrastructure.UWP
|
|||||||
|
|
||||||
public int EntryCount => _mru.Entries.Count;
|
public int EntryCount => _mru.Entries.Count;
|
||||||
|
|
||||||
public async Task<FileInfo> Get(string token)
|
public async Task<FileInfo> Get(string token, bool updateAccessTime = false)
|
||||||
{
|
{
|
||||||
var recentEntry = _mru.Entries.FirstOrDefault(e => e.Token == token);
|
var file = await _mru.GetFileAsync(token, updateAccessTime ? AccessCacheOptions.None : AccessCacheOptions.SuppressAccessTimeUpdate);
|
||||||
var file = await _mru.GetFileAsync(token);
|
|
||||||
StorageApplicationPermissions.FutureAccessList.AddOrReplace(token, file);
|
StorageApplicationPermissions.FutureAccessList.AddOrReplace(token, file);
|
||||||
return new FileInfo
|
return new FileInfo
|
||||||
{
|
{
|
||||||
|
@@ -33,8 +33,13 @@ namespace ModernKeePass.KeePassDatabaseTests
|
|||||||
var pwEntry = new PwEntry(true, true)
|
var pwEntry = new PwEntry(true, true)
|
||||||
{
|
{
|
||||||
ExpiryTime = DateTime.Now,
|
ExpiryTime = DateTime.Now,
|
||||||
BackgroundColor = Color.White,
|
ParentGroup =
|
||||||
ForegroundColor = Color.Black
|
{
|
||||||
|
Uuid = new PwUuid(true),
|
||||||
|
Name = "Parent Group"
|
||||||
|
}
|
||||||
|
//BackgroundColor = Color.White,
|
||||||
|
//ForegroundColor = Color.Black
|
||||||
};
|
};
|
||||||
pwEntry.Strings.Set(PwDefs.TitleField, new ProtectedString(true, "Test"));
|
pwEntry.Strings.Set(PwDefs.TitleField, new ProtectedString(true, "Test"));
|
||||||
pwEntry.Strings.Set(PwDefs.UserNameField, new ProtectedString(true, "toto"));
|
pwEntry.Strings.Set(PwDefs.UserNameField, new ProtectedString(true, "toto"));
|
||||||
@@ -46,8 +51,11 @@ namespace ModernKeePass.KeePassDatabaseTests
|
|||||||
var entry = _mapper.Map<PwEntry, EntryEntity>(pwEntry);
|
var entry = _mapper.Map<PwEntry, EntryEntity>(pwEntry);
|
||||||
|
|
||||||
Assert.That(entry.ExpirationDate, Is.Not.EqualTo(default(DateTimeOffset)));
|
Assert.That(entry.ExpirationDate, Is.Not.EqualTo(default(DateTimeOffset)));
|
||||||
Assert.That(entry.BackgroundColor, Is.EqualTo(Color.White));
|
//Assert.That(entry.BackgroundColor, Is.EqualTo(Color.White));
|
||||||
Assert.That(entry.ForegroundColor, Is.EqualTo(Color.Black));
|
//Assert.That(entry.ForegroundColor, Is.EqualTo(Color.Black));
|
||||||
|
Assert.That(entry.ParentId, Is.Not.EqualTo(PwUuid.Zero.ToHexString()));
|
||||||
|
Assert.That(entry.ParentName, Is.EqualTo("Parent Group"));
|
||||||
|
Assert.That(entry.UserName, Is.EqualTo("toto"));
|
||||||
Assert.That(entry.Name, Is.EqualTo("Test"));
|
Assert.That(entry.Name, Is.EqualTo("Test"));
|
||||||
Assert.That(entry.UserName, Is.EqualTo("toto"));
|
Assert.That(entry.UserName, Is.EqualTo("toto"));
|
||||||
Assert.That(entry.Password, Is.EqualTo("password"));
|
Assert.That(entry.Password, Is.EqualTo("password"));
|
||||||
@@ -69,8 +77,8 @@ namespace ModernKeePass.KeePassDatabaseTests
|
|||||||
Url = new Uri("http://google.com"),
|
Url = new Uri("http://google.com"),
|
||||||
Notes = "blabla",
|
Notes = "blabla",
|
||||||
ExpirationDate = DateTimeOffset.Now,
|
ExpirationDate = DateTimeOffset.Now,
|
||||||
BackgroundColor = Color.White,
|
//BackgroundColor = Color.White,
|
||||||
ForegroundColor = Color.Black,
|
//ForegroundColor = Color.Black,
|
||||||
AdditionalFields = new Dictionary<string, string> {
|
AdditionalFields = new Dictionary<string, string> {
|
||||||
{
|
{
|
||||||
"additional", "custom"
|
"additional", "custom"
|
||||||
@@ -82,8 +90,8 @@ namespace ModernKeePass.KeePassDatabaseTests
|
|||||||
_mapper.Map(entry, pwEntry);
|
_mapper.Map(entry, pwEntry);
|
||||||
|
|
||||||
Assert.That(pwEntry.ExpiryTime, Is.Not.EqualTo(default(DateTime)));
|
Assert.That(pwEntry.ExpiryTime, Is.Not.EqualTo(default(DateTime)));
|
||||||
Assert.That(pwEntry.BackgroundColor, Is.EqualTo(Color.White));
|
//Assert.That(pwEntry.BackgroundColor, Is.EqualTo(Color.White));
|
||||||
Assert.That(pwEntry.ForegroundColor, Is.EqualTo(Color.Black));
|
//Assert.That(pwEntry.ForegroundColor, Is.EqualTo(Color.Black));
|
||||||
Assert.That(pwEntry.Strings.GetSafe(PwDefs.TitleField).ReadString(), Is.EqualTo("Test"));
|
Assert.That(pwEntry.Strings.GetSafe(PwDefs.TitleField).ReadString(), Is.EqualTo("Test"));
|
||||||
Assert.That(pwEntry.Strings.GetSafe(PwDefs.UserNameField).ReadString(), Is.EqualTo("toto"));
|
Assert.That(pwEntry.Strings.GetSafe(PwDefs.UserNameField).ReadString(), Is.EqualTo("toto"));
|
||||||
Assert.That(pwEntry.Strings.GetSafe(PwDefs.PasswordField).ReadString(), Is.EqualTo("password"));
|
Assert.That(pwEntry.Strings.GetSafe(PwDefs.PasswordField).ReadString(), Is.EqualTo("password"));
|
||||||
|
@@ -9,7 +9,6 @@ using ModernKeePass.Domain.Interfaces;
|
|||||||
using ModernKeePass.Infrastructure.KeePass;
|
using ModernKeePass.Infrastructure.KeePass;
|
||||||
using NSubstitute;
|
using NSubstitute;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using FileInfo = ModernKeePass.Domain.Dtos.FileInfo;
|
|
||||||
|
|
||||||
namespace ModernKeePass.KeePassDatabaseTests
|
namespace ModernKeePass.KeePassDatabaseTests
|
||||||
{
|
{
|
||||||
@@ -17,106 +16,99 @@ namespace ModernKeePass.KeePassDatabaseTests
|
|||||||
public class DatabaseTests
|
public class DatabaseTests
|
||||||
{
|
{
|
||||||
private IDatabaseProxy _database;
|
private IDatabaseProxy _database;
|
||||||
private FileInfo _fileInfo;
|
private IFileProxy _fileProxy;
|
||||||
private readonly Credentials _credentials = new Credentials
|
private readonly Credentials _credentials = new Credentials
|
||||||
{
|
{
|
||||||
Password = "test"
|
Password = "test"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
var dateTime = Substitute.For<IDateTime>();
|
var dateTime = Substitute.For<IDateTime>();
|
||||||
var fileProxy = Substitute.For<IFileProxy>();
|
_fileProxy = Substitute.For<IFileProxy>();
|
||||||
fileProxy.OpenBinaryFile(Arg.Any<string>()).Returns(async parameters =>
|
_fileProxy.OpenBinaryFile(Arg.Any<string>()).Returns(async parameters =>
|
||||||
{
|
{
|
||||||
await using var stream = File.Open((string) parameters[0], FileMode.OpenOrCreate);
|
await using var stream = File.Open((string) parameters[0], FileMode.OpenOrCreate);
|
||||||
var contents = new byte[stream.Length];
|
var contents = new byte[stream.Length];
|
||||||
await stream.ReadAsync(contents, 0, (int) stream.Length);
|
await stream.ReadAsync(contents, 0, (int) stream.Length);
|
||||||
return contents;
|
return contents;
|
||||||
});
|
});
|
||||||
fileProxy.WriteBinaryContentsToFile(Arg.Any<string>(), Arg.Any<byte[]>()).Returns(async parameters =>
|
_fileProxy.WriteBinaryContentsToFile(Arg.Any<string>(), Arg.Any<byte[]>()).Returns(async parameters =>
|
||||||
{
|
{
|
||||||
await using var stream = File.Open((string)parameters[0], FileMode.OpenOrCreate);
|
await using var stream = File.Open((string)parameters[0], FileMode.OpenOrCreate);
|
||||||
var contents = (byte[]) parameters[1];
|
var contents = (byte[]) parameters[1];
|
||||||
await stream.WriteAsync(contents, 0, contents.Length);
|
await stream.WriteAsync(contents, 0, contents.Length);
|
||||||
});
|
});
|
||||||
var mapper = new Mapper(new MapperConfiguration(cfg => { cfg.AddProfile(typeof(EntryMappingProfile)); }));
|
var mapper = new Mapper(new MapperConfiguration(cfg => { cfg.AddProfile(typeof(EntryMappingProfile)); }));
|
||||||
_database = new KeePassDatabaseClient(fileProxy, mapper, dateTime);
|
_database = new KeePassDatabaseClient(mapper, dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TearDown]
|
[TearDown]
|
||||||
public void TearDown()
|
public void TearDown()
|
||||||
{
|
{
|
||||||
_database.CloseDatabase();
|
_database.CloseDatabase();
|
||||||
if (!string.IsNullOrEmpty(_fileInfo?.Path)) File.Delete(_fileInfo.Path);
|
//if (!string.IsNullOrEmpty(_fileInfo?.Path)) File.Delete(_fileInfo.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task TestOpen()
|
public async Task TestOpen()
|
||||||
{
|
{
|
||||||
var fileInfo = new FileInfo
|
var file = await _fileProxy.OpenBinaryFile(Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx"));
|
||||||
{
|
|
||||||
Path = Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx")
|
|
||||||
};
|
|
||||||
|
|
||||||
var rootGroup = await _database.Open(fileInfo, _credentials);
|
await _database.Open(file, _credentials);
|
||||||
Assert.That(rootGroup.Name, Is.EqualTo("TestDatabase"));
|
var rootGroup = _database.GetGroup(_database.RootGroupId);
|
||||||
Assert.That(rootGroup.Entries.Count(), Is.EqualTo(2));
|
|
||||||
|
Assert.That(_database.Name, Is.EqualTo("TestDatabase"));
|
||||||
|
Assert.That(rootGroup.Entries.Count, Is.EqualTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task TestCreateAndSave()
|
public async Task TestCreateAndSave()
|
||||||
{
|
{
|
||||||
_fileInfo = new FileInfo
|
var path = Path.Combine(Path.GetTempPath(), "NewDatabase.kdbx");
|
||||||
{
|
var newFile = await _fileProxy.OpenBinaryFile(path);
|
||||||
Path = Path.Combine(Path.GetTempPath(), "NewDatabase.kdbx")
|
|
||||||
};
|
|
||||||
|
|
||||||
await _database.Create(_fileInfo, _credentials);
|
await _database.Create(newFile, _credentials);
|
||||||
await _database.SaveDatabase();
|
var result = await _database.SaveDatabase();
|
||||||
|
await _fileProxy.WriteBinaryContentsToFile(path, result);
|
||||||
_database.CloseDatabase();
|
_database.CloseDatabase();
|
||||||
|
|
||||||
Assert.DoesNotThrowAsync(async () => { await _database.Open(_fileInfo, _credentials); });
|
Assert.DoesNotThrowAsync(async () => { await _database.Open(newFile, _credentials); });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task TestSaveAs()
|
public async Task TestSaveAs()
|
||||||
{
|
{
|
||||||
var originalFileInfo = new FileInfo
|
var currentPath = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx");
|
||||||
{
|
var originalFile = await _fileProxy.OpenBinaryFile(Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx"));
|
||||||
Path = Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx")
|
var currentFile = await _fileProxy.OpenBinaryFile(currentPath);
|
||||||
};
|
await _database.Open(originalFile, _credentials);
|
||||||
_fileInfo = new FileInfo
|
|
||||||
{
|
|
||||||
Path = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx")
|
|
||||||
};
|
|
||||||
|
|
||||||
await _database.Open(originalFileInfo, _credentials);
|
var result = await _database.SaveDatabase(currentFile);
|
||||||
await _database.SaveDatabase(_fileInfo.Path);
|
await _fileProxy.WriteBinaryContentsToFile(currentPath, result);
|
||||||
_database.CloseDatabase();
|
_database.CloseDatabase();
|
||||||
|
|
||||||
Assert.DoesNotThrowAsync(async () => { await _database.Open(_fileInfo, _credentials); });
|
Assert.DoesNotThrowAsync(async () => { await _database.Open(currentFile, _credentials); });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task TestAddGroup()
|
public async Task TestAddGroup()
|
||||||
{
|
{
|
||||||
var originalFileInfo = new FileInfo
|
var currentPath = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx");
|
||||||
{
|
var originalFile = await _fileProxy.OpenBinaryFile(Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx"));
|
||||||
Path = Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx")
|
var currentFile = await _fileProxy.OpenBinaryFile(currentPath);
|
||||||
};
|
|
||||||
_fileInfo = new FileInfo
|
|
||||||
{
|
|
||||||
Path = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx")
|
|
||||||
};
|
|
||||||
var newGroup = new GroupEntity {Name = "New Group Test"};
|
var newGroup = new GroupEntity {Name = "New Group Test"};
|
||||||
|
await _database.Open(originalFile, _credentials);
|
||||||
|
|
||||||
var rootGroup = await _database.Open(originalFileInfo, _credentials);
|
await _database.AddGroup(_database.RootGroupId, newGroup.Id);
|
||||||
await _database.AddGroup(rootGroup.Id, newGroup.Id);
|
var result = await _database.SaveDatabase(currentFile);
|
||||||
await _database.SaveDatabase(_fileInfo.Path);
|
await _fileProxy.WriteBinaryContentsToFile(currentPath, result);
|
||||||
_database.CloseDatabase();
|
_database.CloseDatabase();
|
||||||
rootGroup = await _database.Open(_fileInfo, _credentials);
|
|
||||||
|
await _database.Open(currentFile, _credentials);
|
||||||
|
var rootGroup = _database.GetGroup(_database.RootGroupId);
|
||||||
|
|
||||||
Assert.That(newGroup.Id, Is.Not.Empty);
|
Assert.That(newGroup.Id, Is.Not.Empty);
|
||||||
Assert.That(rootGroup.SubGroups.Count, Is.EqualTo(7));
|
Assert.That(rootGroup.SubGroups.Count, Is.EqualTo(7));
|
||||||
@@ -126,24 +118,22 @@ namespace ModernKeePass.KeePassDatabaseTests
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task TestAddEntry()
|
public async Task TestAddEntry()
|
||||||
{
|
{
|
||||||
var originalFileInfo = new FileInfo
|
var currentPath = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx");
|
||||||
{
|
|
||||||
Path = Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx")
|
|
||||||
};
|
|
||||||
_fileInfo = new FileInfo
|
|
||||||
{
|
|
||||||
Path = Path.Combine(Path.GetTempPath(), "SavedDatabase.kdbx")
|
|
||||||
};
|
|
||||||
var newEntry = new EntryEntity
|
var newEntry = new EntryEntity
|
||||||
{
|
{
|
||||||
Name = "New Entry Test"
|
Name = "New Entry Test"
|
||||||
};
|
};
|
||||||
|
var originalFile = await _fileProxy.OpenBinaryFile(Path.Combine(Directory.GetCurrentDirectory(), "Data", "TestDatabase.kdbx"));
|
||||||
|
var currentFile = await _fileProxy.OpenBinaryFile(currentPath);
|
||||||
|
await _database.Open(originalFile, _credentials);
|
||||||
|
|
||||||
var rootGroup = await _database.Open(originalFileInfo, _credentials);
|
await _database.AddEntry(_database.RootGroupId, newEntry.Id);
|
||||||
await _database.AddEntry(rootGroup.Id, newEntry.Id);
|
var result = await _database.SaveDatabase(currentFile);
|
||||||
await _database.SaveDatabase(_fileInfo.Path);
|
await _fileProxy.WriteBinaryContentsToFile(currentPath, result);
|
||||||
_database.CloseDatabase();
|
_database.CloseDatabase();
|
||||||
rootGroup = await _database.Open(_fileInfo, _credentials);
|
|
||||||
|
await _database.Open(currentFile, _credentials);
|
||||||
|
var rootGroup = _database.GetGroup(_database.RootGroupId);
|
||||||
|
|
||||||
Assert.That(newEntry.Id, Is.Not.Empty);
|
Assert.That(newEntry.Id, Is.Not.Empty);
|
||||||
Assert.That(rootGroup.Entries.Count, Is.EqualTo(3));
|
Assert.That(rootGroup.Entries.Count, Is.EqualTo(3));
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
|
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
|
||||||
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.15.0.2" />
|
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.16.0.2" />
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>ModernKeePass</DisplayName>
|
<DisplayName>ModernKeePass</DisplayName>
|
||||||
<PublisherDisplayName>wismna</PublisherDisplayName>
|
<PublisherDisplayName>wismna</PublisherDisplayName>
|
||||||
|
@@ -3,6 +3,8 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
|
using ModernKeePass.Application.Database.Commands.CreateDatabase;
|
||||||
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
||||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||||
using ModernKeePass.Application.Database.Queries.OpenDatabase;
|
using ModernKeePass.Application.Database.Queries.OpenDatabase;
|
||||||
@@ -110,13 +112,15 @@ namespace ModernKeePass.ViewModels
|
|||||||
private string _keyFilePath;
|
private string _keyFilePath;
|
||||||
private string _keyFileText;
|
private string _keyFileText;
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
|
private readonly ISettingsProxy _settings;
|
||||||
private readonly ResourceHelper _resource;
|
private readonly ResourceHelper _resource;
|
||||||
|
|
||||||
public CompositeKeyVm() : this(App.Services.GetService<IMediator>()) { }
|
public CompositeKeyVm() : this(App.Services.GetService<IMediator>(), App.Services.GetService<ISettingsProxy>()) { }
|
||||||
|
|
||||||
public CompositeKeyVm(IMediator mediator)
|
public CompositeKeyVm(IMediator mediator, ISettingsProxy settings)
|
||||||
{
|
{
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
|
_settings = settings;
|
||||||
_resource = new ResourceHelper();
|
_resource = new ResourceHelper();
|
||||||
_keyFileText = _resource.GetResourceValue("CompositeKeyDefaultKeyFile");
|
_keyFileText = _resource.GetResourceValue("CompositeKeyDefaultKeyFile");
|
||||||
}
|
}
|
||||||
@@ -127,12 +131,25 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
_isOpening = true;
|
_isOpening = true;
|
||||||
OnPropertyChanged(nameof(IsValid));
|
OnPropertyChanged(nameof(IsValid));
|
||||||
|
if (createNew)
|
||||||
await _mediator.Send(new OpenDatabaseQuery {
|
{
|
||||||
FilePath = databaseFilePath,
|
await _mediator.Send(new CreateDatabaseCommand
|
||||||
KeyFilePath = HasKeyFile ? KeyFilePath : null,
|
{
|
||||||
Password = HasPassword ? Password : null,
|
FilePath = databaseFilePath,
|
||||||
});
|
KeyFilePath = HasKeyFile ? KeyFilePath : null,
|
||||||
|
Password = HasPassword ? Password : null,
|
||||||
|
Name = "New Database",
|
||||||
|
CreateSampleData = _settings.GetSetting<bool>("Sample")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _mediator.Send(new OpenDatabaseQuery {
|
||||||
|
FilePath = databaseFilePath,
|
||||||
|
KeyFilePath = HasKeyFile ? KeyFilePath : null,
|
||||||
|
Password = HasPassword ? Password : null,
|
||||||
|
});
|
||||||
|
}
|
||||||
RootGroupId = (await _mediator.Send(new GetDatabaseQuery())).RootGroupId;
|
RootGroupId = (await _mediator.Send(new GetDatabaseQuery())).RootGroupId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
// Called from XAML
|
// Called from XAML
|
||||||
public void UpdateAccessTime()
|
public void UpdateAccessTime()
|
||||||
{
|
{
|
||||||
_recent.Get(Token).Wait();
|
_recent.Get(Token, true).Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using Windows.Storage;
|
||||||
using Windows.Storage;
|
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
|
||||||
using ModernKeePass.Application.Entry.Commands.SetFieldValue;
|
|
||||||
using ModernKeePass.Application.Group.Commands.CreateEntry;
|
|
||||||
using ModernKeePass.Application.Group.Commands.CreateGroup;
|
|
||||||
using ModernKeePass.Application.Group.Models;
|
|
||||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
|
||||||
using ModernKeePass.Domain.Enums;
|
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
@@ -18,7 +10,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
private readonly ISettingsProxy _settings;
|
private readonly ISettingsProxy _settings;
|
||||||
private string _importFormatHelp;
|
private string _importFormatHelp;
|
||||||
public string Password { get; set; }
|
|
||||||
|
|
||||||
public bool IsImportChecked { get; set; }
|
public bool IsImportChecked { get; set; }
|
||||||
|
|
||||||
@@ -45,57 +36,5 @@ namespace ModernKeePass.ViewModels
|
|||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<GroupVm> PopulateInitialData()
|
|
||||||
{
|
|
||||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
|
||||||
var rootGroup = await _mediator.Send(new GetGroupQuery {Id = database.RootGroupId});
|
|
||||||
if (_settings.GetSetting<bool>("Sample") && !IsImportChecked) await CreateSampleData(rootGroup);
|
|
||||||
return rootGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task CreateSampleData(GroupVm group)
|
|
||||||
{
|
|
||||||
/*var converter = new IntToSymbolConverter();
|
|
||||||
|
|
||||||
var bankingGroup = group.AddNewGroup("Banking");
|
|
||||||
bankingGroup.Icon = (int)converter.ConvertBack(Symbol.Calculator, null, null, string.Empty);
|
|
||||||
|
|
||||||
var emailGroup = group.AddNewGroup("Email");
|
|
||||||
emailGroup.Icon = (int)converter.ConvertBack(Symbol.Mail, null, null, string.Empty);
|
|
||||||
|
|
||||||
var internetGroup = group.AddNewGroup("Internet");
|
|
||||||
internetGroup.Icon = (int)converter.ConvertBack(Symbol.World, null, null, string.Empty);
|
|
||||||
|
|
||||||
var sample1 = group.AddNewEntry();
|
|
||||||
sample1.Title = "Sample Entry";
|
|
||||||
sample1.UserName = "Username";
|
|
||||||
sample1.Url = PwDefs.HomepageUrl;
|
|
||||||
sample1.Password = "Password";
|
|
||||||
sample1.Notes = "You may safely delete this sample";
|
|
||||||
|
|
||||||
var sample2 = group.AddNewEntry();
|
|
||||||
sample2.Title = "Sample Entry #2";
|
|
||||||
sample2.UserName = "Michael321";
|
|
||||||
sample2.Url = PwDefs.HelpUrl + "kb/testform.html";
|
|
||||||
sample2.Password = "12345";*/
|
|
||||||
|
|
||||||
var bankingGroup = await _mediator.Send(new CreateGroupCommand {ParentGroup = group, Name = "Banking"});
|
|
||||||
var emailGroup = await _mediator.Send(new CreateGroupCommand {ParentGroup = group, Name = "Email" });
|
|
||||||
var internetGroup = await _mediator.Send(new CreateGroupCommand {ParentGroup = group, Name = "Internet" });
|
|
||||||
|
|
||||||
var sample1 = await _mediator.Send(new CreateEntryCommand { ParentGroup = group });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample1.Id, FieldName = EntryFieldName.Title, FieldValue = "Sample Entry"});
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample1.Id, FieldName = EntryFieldName.UserName, FieldValue = "Username" });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample1.Id, FieldName = EntryFieldName.Password, FieldValue = "Password" });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample1.Id, FieldName = EntryFieldName.Url, FieldValue = "https://keepass.info/" });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample1.Id, FieldName = EntryFieldName.Notes, FieldValue = "You may safely delete this sample" });
|
|
||||||
|
|
||||||
var sample2 = await _mediator.Send(new CreateEntryCommand { ParentGroup = group });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample2.Id, FieldName = EntryFieldName.Title, FieldValue = "Sample Entry #2"});
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample2.Id, FieldName = EntryFieldName.UserName, FieldValue = "Michael321" });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample2.Id, FieldName = EntryFieldName.Password, FieldValue = "12345" });
|
|
||||||
await _mediator.Send(new SetFieldValueCommand {EntryId = sample2.Id, FieldName = EntryFieldName.Url, FieldValue = "https://keepass.info/help/kb/testform.html" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ namespace ModernKeePass.Views.BasePages
|
|||||||
/// The source of the event; typically <see cref="Common.NavigationHelper"/>
|
/// The source of the event; typically <see cref="Common.NavigationHelper"/>
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="e">Event data that provides both the navigation parameter passed to
|
/// <param name="e">Event data that provides both the navigation parameter passed to
|
||||||
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
|
/// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and
|
||||||
/// a dictionary of state preserved by this page during an earlier
|
/// a dictionary of state preserved by this page during an earlier
|
||||||
/// session. The state will be null the first time a page is visited.</param>
|
/// session. The state will be null the first time a page is visited.</param>
|
||||||
protected void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
|
protected void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
<ColumnDefinition Width="{StaticResource MenuGridLength}" x:Name="LeftListViewColumn" />
|
<ColumnDefinition Width="{StaticResource MenuGridLength}" x:Name="LeftListViewColumn" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<userControls:HamburgerMenuUserControl x:Uid="GroupsLeftListView" ItemsSource="{Binding Groups}" SelectionChanged="groups_SelectionChanged" ButtonClicked="CreateGroup_ButtonClick" ResizeTarget="{Binding ElementName=LeftListViewColumn}" IsButtonVisible="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}" />
|
<userControls:HamburgerMenuUserControl x:Uid="GroupsLeftListView" ItemsSource="{Binding Groups}" SelectionChanged="groups_SelectionChanged" ButtonClicked="CreateGroup_ButtonClick" ResizeTarget="{Binding ElementName=LeftListViewColumn}" IsButtonVisible="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}" IsOpen="true" />
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
xmlns:converters="using:ModernKeePass.Converters"
|
xmlns:converters="using:ModernKeePass.Converters"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||||
|
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||||
|
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
@@ -21,7 +23,13 @@
|
|||||||
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding IsFileSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding IsFileSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
<StackPanel Margin="25,0,25,0">
|
<StackPanel Margin="25,0,25,0">
|
||||||
<TextBlock Text="{Binding Name}" />
|
<TextBlock Text="{Binding Name}" />
|
||||||
<userControls:CompositeKeyUserControl x:Uid="CompositeKeyNewButton" CreateNew="True" DatabaseFilePath="{Binding Token}" ValidationChecked="CompositeKeyUserControl_OnValidationChecked" />
|
<userControls:CompositeKeyUserControl x:Uid="CompositeKeyNewButton" CreateNew="True" DatabaseFilePath="{Binding Token}">
|
||||||
|
<interactivity:Interaction.Behaviors>
|
||||||
|
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||||
|
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.GroupDetailPage" />
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
|
</interactivity:Interaction.Behaviors>
|
||||||
|
</userControls:CompositeKeyUserControl>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
<CheckBox x:Name="CheckBox" x:Uid="NewImportCheckbox" Margin="15,10,0,0" IsChecked="{Binding IsImportChecked, Mode=TwoWay}" Visibility="{Binding IsFileSelected, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
<CheckBox x:Name="CheckBox" x:Uid="NewImportCheckbox" Margin="15,10,0,0" IsChecked="{Binding IsImportChecked, Mode=TwoWay}" Visibility="{Binding IsFileSelected, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||||
|
@@ -85,11 +85,5 @@ namespace ModernKeePass.Views
|
|||||||
Model.ImportFile = await picker.PickSingleFileAsync();
|
Model.ImportFile = await picker.PickSingleFileAsync();
|
||||||
if (Model.ImportFile != null) ImportFileLink.Content = Model.ImportFile.Name;
|
if (Model.ImportFile != null) ImportFileLink.Content = Model.ImportFile.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void CompositeKeyUserControl_OnValidationChecked(object sender, PasswordEventArgs e)
|
|
||||||
{
|
|
||||||
var rootGroup = await Model.PopulateInitialData();
|
|
||||||
_mainFrame.Navigate(typeof(GroupDetailPage), rootGroup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@
|
|||||||
<ListView.HeaderTemplate>
|
<ListView.HeaderTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<ToggleButton Style="{StaticResource HamburgerToggleButton}">
|
<ToggleButton Style="{StaticResource HamburgerToggleButton}" IsChecked="{Binding Path={Binding IsOpen, ElementName=UserControl}}">
|
||||||
<ToolTipService.ToolTip>
|
<ToolTipService.ToolTip>
|
||||||
<ToolTip Content="{Binding HeaderLabel, ElementName=UserControl}" />
|
<ToolTip Content="{Binding HeaderLabel, ElementName=UserControl}" />
|
||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
|
@@ -100,6 +100,18 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
typeof(HamburgerMenuUserControl),
|
typeof(HamburgerMenuUserControl),
|
||||||
new PropertyMetadata(null, (o, args) => { }));
|
new PropertyMetadata(null, (o, args) => { }));
|
||||||
|
|
||||||
|
public bool IsOpen
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(IsOpenProperty); }
|
||||||
|
set { SetValue(IsOpenProperty, value); }
|
||||||
|
}
|
||||||
|
public static readonly DependencyProperty IsOpenProperty =
|
||||||
|
DependencyProperty.Register(
|
||||||
|
"IsOpen",
|
||||||
|
typeof(bool),
|
||||||
|
typeof(HamburgerMenuUserControl),
|
||||||
|
new PropertyMetadata(false, (o, args) => { }));
|
||||||
|
|
||||||
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
|
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
|
||||||
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user