mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Added unit tests (all passing unfortunately)
UI improvements Write mode still doesn't work
This commit is contained in:
@@ -31,8 +31,11 @@ namespace ModernKeePass.Common
|
||||
_pwDatabase.Open(IOConnectionInfo.FromFile(databaseFile), key, new NullStatusLogger());
|
||||
//_pwDatabase.Open(IOConnectionInfo.FromPath(databaseFile.Path), key, new NullStatusLogger());
|
||||
IsOpen = _pwDatabase.IsOpen;
|
||||
Name = databaseFile.DisplayName;
|
||||
RootGroup = new GroupVm(_pwDatabase.RootGroup);
|
||||
if (IsOpen)
|
||||
{
|
||||
Name = databaseFile.DisplayName;
|
||||
RootGroup = new GroupVm(_pwDatabase.RootGroup);
|
||||
}
|
||||
}
|
||||
catch (ArgumentNullException)
|
||||
{
|
||||
|
@@ -20,7 +20,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListView Grid.Column="0" SelectionChanged="ListView_SelectionChanged">
|
||||
<ListView.Header>
|
||||
<TextBlock Text="Open database from..." FontWeight="Bold" FontSize="36" />
|
||||
<TextBlock Text="ModernKeePass" FontWeight="Bold" FontSize="36" />
|
||||
</ListView.Header>
|
||||
<ListView.ItemTemplate >
|
||||
<DataTemplate>
|
||||
@@ -37,6 +37,7 @@
|
||||
<ListViewItem Name="NewItem">New</ListViewItem>
|
||||
<ListViewItem Name="SelectItem">File</ListViewItem>
|
||||
<ListViewItem Name="RecentItem">Recent files - Coming soon</ListViewItem>
|
||||
<ListViewItem Name="UrlItem">Url files - Coming soon</ListViewItem>
|
||||
</ListView.Items>
|
||||
</ListView>
|
||||
<Grid Name="SelectGrid" Grid.Column="2" HorizontalAlignment="Left" Height="auto" VerticalAlignment="Top" Width="auto" Margin="0,30,0,0" Visibility="Collapsed" >
|
||||
@@ -56,6 +57,6 @@
|
||||
<TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding ErrorMessage}" Foreground="#FF9E1B1B" />
|
||||
<Button Grid.Column="1" Grid.Row="3" x:Name="OpenButton" Content="OK" HorizontalAlignment="Right" VerticalAlignment="Top" Visibility="{Binding Visibility}" Click="openBbutton_Click" Margin="0,0,7,0" Width="auto"/>
|
||||
</Grid>
|
||||
<HyperlinkButton Grid.Column="2" Name="SaveButton" Content="Save file" Click="saveBbutton_Click" VerticalAlignment="Top" Margin="0,30,0,0" Visibility="Collapsed" />
|
||||
<HyperlinkButton Grid.Column="2" Name="SaveButton" Content="Save file" Click="saveBbutton_Click" VerticalAlignment="Top" Margin="0,30,0,0" Visibility="Collapsed" IsEnabled="{Binding IsOpen}" />
|
||||
</Grid>
|
||||
</Page>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.Pages;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace ModernKeePass
|
||||
var homeVm = DataContext as HomeVm;
|
||||
var app = ((App)Application.Current);
|
||||
homeVm.ErrorMessage = app.Database.Open(homeVm.Password);
|
||||
if (!app.Database.IsOpen) homeVm.NotifyPropertyChanged("ErrorMessage");
|
||||
|
||||
if (!string.IsNullOrEmpty(homeVm.ErrorMessage)) homeVm.NotifyPropertyChanged("ErrorMessage");
|
||||
else Frame.Navigate(typeof(GroupDetailPage), app.Database.RootGroup);
|
||||
}
|
||||
|
||||
@@ -71,5 +72,15 @@ namespace ModernKeePass
|
||||
SelectGrid.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
var app = (App)Application.Current;
|
||||
if (app.Database == null) return;
|
||||
var homeVm = DataContext as HomeVm;
|
||||
homeVm.IsOpen = app.Database.IsOpen;
|
||||
homeVm.NotifyPropertyChanged("IsOpen");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -163,8 +163,8 @@
|
||||
<HintPath>..\packages\Portable.BouncyCastle.1.8.1.1\lib\netstandard1.0\crypto.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ModernKeePassLibPCL, Version=2.28.1.22258, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ModernKeePassLibPCL.2.28.1.22258\lib\netstandard1.2\ModernKeePassLibPCL.dll</HintPath>
|
||||
<Reference Include="ModernKeePassLibPCL, Version=2.28.1.31251, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ModernKeePassLibPCL.2.28.1.31251\lib\netstandard1.2\ModernKeePassLibPCL.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PCLCrypto, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d4421c8a4786956c, processorArchitecture=MSIL">
|
||||
|
@@ -65,7 +65,7 @@
|
||||
</GridView.ItemTemplate>
|
||||
<GridView.Header>
|
||||
<StackPanel Width="480" Margin="0,4,14,0">
|
||||
<ListView x:Name="entriesListView" Height="100" ItemsSource="{Binding Source={StaticResource entriesViewSource}}" Margin="10,0,0,0" SelectionChanged="entriesListView_SelectionChanged">
|
||||
<ListView x:Name="entriesListView" Height="auto" ItemsSource="{Binding Source={StaticResource entriesViewSource}}" Margin="10,0,0,0" SelectionChanged="entriesListView_SelectionChanged">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -77,8 +77,6 @@
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
<Button x:Name="addGroupButton" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="addGroupButton_Click" Content="Add Group" />
|
||||
</StackPanel>
|
||||
</GridView.Header>
|
||||
<GridView.ItemContainerStyle>
|
||||
|
@@ -89,11 +89,5 @@ namespace ModernKeePass.Pages
|
||||
var listView = sender as ListView;
|
||||
Frame.Navigate(typeof(EntryDetailPage), listView.SelectedItem as EntryVm);
|
||||
}
|
||||
|
||||
private void addGroupButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
var group = DataContext as GroupVm;
|
||||
group.AddGroup("New group");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class EntryVm : INotifyPropertyChanged
|
||||
{
|
||||
public string Title { get; private set; }
|
||||
public string Title { get; set; }
|
||||
public string UserName { get; private set; }
|
||||
public string Password { get; private set; }
|
||||
public string URL { get; private set; }
|
||||
|
@@ -32,27 +32,34 @@ namespace ModernKeePass.ViewModels
|
||||
Name = "GroupName";
|
||||
Entries = new ObservableCollection<EntryVm>();
|
||||
Groups = new ObservableCollection<GroupVm>();
|
||||
|
||||
}
|
||||
|
||||
public GroupVm(PwGroup group)
|
||||
public GroupVm(PwGroup pwGroup)
|
||||
{
|
||||
_pwGroup = group;
|
||||
Name = group.Name;
|
||||
Entries = new ObservableCollection<EntryVm>(group.Entries.Select(e => new EntryVm(e)));
|
||||
Groups = new ObservableCollection<GroupVm>(group.Groups.Select(g => new GroupVm(g)));
|
||||
_pwGroup = pwGroup;
|
||||
Name = pwGroup.Name;
|
||||
Entries = new ObservableCollection<EntryVm>(pwGroup.Entries.Select(e => new EntryVm(e)));
|
||||
//Entries.Insert(0, new EntryVm { Title = " + New entry" });
|
||||
Groups = new ObservableCollection<GroupVm>(pwGroup.Groups.Select(g => new GroupVm(g)));
|
||||
//Groups.Insert(0, new GroupVm { Name = " + New group" });
|
||||
}
|
||||
|
||||
public void AddGroup(string title)
|
||||
public void CreateNewGroup(string title)
|
||||
{
|
||||
var pwGroup = new PwGroup
|
||||
{
|
||||
Name = title
|
||||
};
|
||||
var pwGroup = new PwGroup(true, true, title, PwIcon.Folder);
|
||||
_pwGroup.AddGroup(pwGroup, true);
|
||||
Groups.Add(new GroupVm(pwGroup));
|
||||
NotifyPropertyChanged("Groups");
|
||||
this._pwGroup.Groups.Add(pwGroup);
|
||||
}
|
||||
|
||||
public void CreateNewEntry(string title)
|
||||
{
|
||||
var pwEntry = new PwEntry(true, true);
|
||||
_pwGroup.AddEntry(pwEntry, true);
|
||||
Entries.Add(new EntryVm(pwEntry));
|
||||
NotifyPropertyChanged("Entries");
|
||||
}
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
@@ -8,6 +8,7 @@ namespace ModernKeePass.ViewModels
|
||||
public string Password { get; set; }
|
||||
public Visibility Visibility { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
public bool IsOpen { get; set; }
|
||||
|
||||
public HomeVm()
|
||||
{
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<package id="Microsoft.Bcl.Compression" version="3.9.85" targetFramework="win81" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="2.0.0" targetFramework="win81" />
|
||||
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" />
|
||||
<package id="ModernKeePassLibPCL" version="2.28.1.22258" targetFramework="win81" />
|
||||
<package id="ModernKeePassLibPCL" version="2.28.1.31251" targetFramework="win81" />
|
||||
<package id="NETStandard.Library" version="2.0.0" targetFramework="win81" />
|
||||
<package id="PCLCrypto" version="2.0.147" targetFramework="win81" />
|
||||
<package id="PCLStorage" version="1.0.2" targetFramework="win81" />
|
||||
|
Reference in New Issue
Block a user