6 Commits
V1.2 ... V1.3

Author SHA1 Message Date
86064af3a2 Package information updated 2017-11-08 14:42:40 +01:00
3265244f06 Update project version and manifest versions 2017-11-08 14:42:40 +01:00
2698070328 Creating groups and entries now navigates to the related detail page, in edit mode
Code cleanup
2017-11-08 14:42:40 +01:00
5638b59fda Corrected Entry password not synchronized bug
Created a new welcome page to be shown on first launch
Added descriptive text in main menu pages
2017-11-08 14:42:40 +01:00
9f94dd55c2 Added ViewModel property in code behind of all pages
Workaround a bug in Entry password reveal when set for the first time
2017-11-08 14:42:40 +01:00
0ded991673 Code cleanup 2017-11-08 14:42:40 +01:00
26 changed files with 202 additions and 131 deletions

View File

@@ -1,4 +1,4 @@
MainPackage=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.2.0.14_AnyCPU.appx
SymbolPackage=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\AppPackages\ModernKeePass_1.2.0.14_Test\ModernKeePass_1.2.0.14_AnyCPU.appxsym
ResourcePack=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.2.0.14_scale-140.appx
ResourcePack=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.2.0.14_scale-180.appx
MainPackage=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.3.0.17_AnyCPU.appx
SymbolPackage=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\AppPackages\ModernKeePass_1.3.0.17_Test\ModernKeePass_1.3.0.17_AnyCPU.appxsym
ResourcePack=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.3.0.17_scale-140.appx
ResourcePack=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.3.0.17_scale-180.appx

View File

@@ -334,11 +334,6 @@
</UserControl.Resources>
<StackPanel>
<PasswordBox x:Name="PasswordBox" Width="300" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" Style="{StaticResource PasswordBoxWithButtonStyle}"/>
<!--<StackPanel Orientation="Horizontal" Margin="0,-1,0,-1" >
<Button Click="OpenButton_OnClick" Width="auto" Padding="2,0">
<SymbolIcon Symbol="Forward" />
</Button>
</StackPanel>-->
<TextBlock x:Name="StatusTextBlock" Height="32" Width="auto" Foreground="#FFBF6969" FontSize="16" FontWeight="Bold" />
</StackPanel>
</UserControl>

View File

@@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using ModernKeePass.Common;
using ModernKeePass.Events;
@@ -12,7 +11,7 @@ using ModernKeePass.Events;
namespace ModernKeePass.Controls
{
public sealed partial class OpenDatabaseUserControl : UserControl
public sealed partial class OpenDatabaseUserControl
{
public bool CreateNew
{

View File

@@ -1,5 +1,6 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using ModernKeePass.Pages;
using ModernKeePass.ViewModels;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
@@ -9,8 +10,10 @@ namespace ModernKeePass
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
public sealed partial class MainPage
{
public MainVm Model => (MainVm)DataContext;
public MainPage()
{
InitializeComponent();
@@ -20,12 +23,12 @@ namespace ModernKeePass
{
base.OnNavigatedTo(e);
DataContext = new MainVm(Frame, MenuFrame);
if (Model.SelectedItem == null) MenuFrame.Navigate(typeof(WelcomePage));
}
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var mainVm = DataContext as MainVm;
mainVm.SelectedItem?.Destination.Navigate(mainVm.SelectedItem.PageType, mainVm.SelectedItem.Parameter);
Model.SelectedItem?.Destination.Navigate(Model.SelectedItem.PageType, Model.SelectedItem.Parameter);
}
}
}

View File

@@ -136,6 +136,9 @@
<Compile Include="Pages\NewDatabasePage.xaml.cs">
<DependentUpon>NewDatabasePage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\WelcomePage.xaml.cs">
<DependentUpon>WelcomePage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\Items\MainMenuItemVm.cs" />
<Compile Include="ViewModels\Items\RecentItemVm.cs" />
<Compile Include="Pages\EntryDetailPage.xaml.cs">
@@ -211,6 +214,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\WelcomePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Styles\HamburgerButtonStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@@ -1,6 +1,6 @@
<?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">
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.2.0.14" />
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.3.0.17" />
<Properties>
<DisplayName>ModernKeePass</DisplayName>
<PublisherDisplayName>wismna</PublisherDisplayName>
@@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="ModernKeePass.App">
<m2:VisualElements DisplayName="ModernKeePass" Square150x150Logo="Assets\ModernKeePass-Logo.png" Square30x30Logo="Assets\ModernKeePass-SmallLogo.png" Description="A port of the KeePass application for the Windows store. For now, it only features read-only capabilites and only opens password protected databases." ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<m2:VisualElements DisplayName="ModernKeePass" Square150x150Logo="Assets\ModernKeePass-Logo.png" Square30x30Logo="Assets\ModernKeePass-SmallLogo.png" Description="A port of the KeePass application for the Windows store. You can create, open and edit KeePass 2.x password databases in a modern fashion." ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<m2:DefaultTile Square310x310Logo="Assets\Square310x310Logo.png" Wide310x150Logo="Assets\Wide310x150Logo.png" Square70x70Logo="Assets\Square70x70Logo.png">
</m2:DefaultTile>
<m2:SplashScreen Image="Assets\ModernKeePass-SplashScreen.png" />

View File

@@ -36,26 +36,20 @@
<Setter Property="Margin" Value="0,20,0,0"/>
</Style>
</StackPanel.Resources>
<TextBlock x:Name="userTextBlock" TextWrapping="Wrap" Text="User name or login" FontSize="18"/>
<TextBox x:Name="userTextBox" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding UserName, Mode=TwoWay}" Width="350" Height="32" />
<TextBlock x:Name="passwordTextBlock" TextWrapping="Wrap" Text="Password" FontSize="18"/>
<PasswordBox x:Name="passwordBox" HorizontalAlignment="Left" Password="{Binding Password, Mode=TwoWay}" Width="350" Height="32" IsPasswordRevealButtonEnabled="True" Visibility="{Binding IsRevealPassword, Converter={StaticResource InverseBooleanToVisibilityConverter}}" />
<TextBox x:Name="passwordTextBox" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Password, Mode=TwoWay}" Width="350" Height="32" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" />
<CheckBox x:Name="checkBox" HorizontalAlignment="Left" Margin="-3,0,0,0" Content="Show password" IsChecked="{Binding IsRevealPassword, Mode=TwoWay}"/>
<TextBlock x:Name="urlTextBlock" TextWrapping="Wrap" Text="URL" FontSize="18"/>
<!--<StackPanel Orientation="Horizontal" Margin="0,-1,0,-1" Width="350" HorizontalAlignment="Left">
<TextBox x:Name="urlTextBox" TextWrapping="Wrap" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Padding="0,0,34,0" />
<Button Click="UrlButton_Click" Height="34" Margin="-34,0,0,0" Background="Transparent" Padding="2,0" >
<SymbolIcon Symbol="Forward" VerticalAlignment="Center" />
</Button>
</StackPanel>-->
<local:TextBoxWithButton x:Name="urlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" GotoClick="UrlButton_Click" />
<TextBlock x:Name="notesTextBlock" TextWrapping="Wrap" Text="Notes" FontSize="18"/>
<TextBox x:Name="notesTextBox" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Notes, Mode=TwoWay}" Width="350" Height="200" AcceptsReturn="True" IsSpellCheckEnabled="True" />
<TextBlock TextWrapping="Wrap" Text="User name or login" FontSize="18"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding UserName, Mode=TwoWay}" Width="350" Height="32" />
<TextBlock TextWrapping="Wrap" Text="Password" FontSize="18"/>
<PasswordBox HorizontalAlignment="Left" Password="{Binding Password, Mode=TwoWay}" Width="350" Height="32" IsPasswordRevealButtonEnabled="True" Visibility="{Binding IsRevealPassword, Converter={StaticResource InverseBooleanToVisibilityConverter}}" />
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Password, Mode=TwoWay}" Width="350" Height="32" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" />
<CheckBox HorizontalAlignment="Left" Margin="-3,0,0,0" Content="Show password" IsChecked="{Binding IsRevealPassword, Mode=TwoWay}" IsEnabled="{Binding IsRevealPasswordEnabled}" />
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
<local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" GotoClick="UrlButton_Click" />
<TextBlock TextWrapping="Wrap" Text="Notes" FontSize="18"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Notes, Mode=TwoWay}" Width="350" Height="200" AcceptsReturn="True" IsSpellCheckEnabled="True" />
</StackPanel>
<!-- Bouton Précédent et titre de la page -->
<Grid>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
@@ -69,13 +63,15 @@
AutomationProperties.ItemType="Navigation Button"/>
<TextBox
Grid.Column="1"
x:Name="TitleTextBox"
Text="{Binding Title, Mode=TwoWay}"
Style="{StaticResource HeaderTextBoxStyle}"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
IsHitTestVisible="{Binding IsEditMode}"
TextWrapping="NoWrap"
VerticalAlignment="Center"
Margin="0,0,30,0"/>
Margin="0,0,30,0"
PlaceholderText="New entry name..."/>
<CommandBar Grid.Column="2" Background="Transparent" IsOpen="True" VerticalAlignment="Center" Margin="0,20,0,0">
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}" />
<AppBarButton Icon="Delete" Label="Delete" Click="AppBarButton_Click" />

View File

@@ -1,9 +1,11 @@
using System;
using System.Threading.Tasks;
using Windows.UI.Core;
using Windows.UI.Popups;
using ModernKeePass.Common;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common;
using ModernKeePass.ViewModels;
// Pour en savoir plus sur le modèle d'élément Page Détail de l'élément, consultez la page http://go.microsoft.com/fwlink/?LinkId=234232
@@ -14,10 +16,12 @@ namespace ModernKeePass.Pages
/// Page affichant les détails d'un élément au sein d'un groupe, offrant la possibilité de
/// consulter les autres éléments qui appartiennent au même groupe.
/// </summary>
public sealed partial class EntryDetailPage : Page
public sealed partial class EntryDetailPage
{
private NavigationHelper navigationHelper;
public EntryVm Model => (EntryVm) DataContext;
/// <summary>
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
/// gestion de la durée de vie des processus
@@ -58,10 +62,12 @@ namespace ModernKeePass.Pages
protected override void OnNavigatedTo(NavigationEventArgs e)
{
navigationHelper.OnNavigatedTo(e);
if (e.Parameter is EntryVm)
{
DataContext = e.Parameter as EntryVm;
}
if (!(e.Parameter is EntryVm)) return;
DataContext = (EntryVm)e.Parameter;
if (Model.IsEditMode)
Task.Factory.StartNew(
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
() => TitleTextBox.Focus(FocusState.Programmatic)));
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -99,7 +105,7 @@ namespace ModernKeePass.Pages
{
try
{
var uri = new Uri(urlTextBox.Text);
var uri = new Uri(UrlTextBox.Text);
await Windows.System.Launcher.LaunchUriAsync(uri);
}
catch

View File

@@ -220,13 +220,15 @@
AutomationProperties.ItemType="Navigation Button"/>
<TextBox
Grid.Column="1"
x:Name="TitleTextBox"
Text="{Binding Name, Mode=TwoWay}"
Style="{StaticResource HeaderTextBoxStyle}"
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
IsHitTestVisible="{Binding IsEditMode}"
TextWrapping="NoWrap"
VerticalAlignment="Center"
Margin="0,0,30,0"/>
Margin="0,0,30,0"
PlaceholderText="New group name..."/>
<CommandBar Grid.Column="2" Background="Transparent" IsOpen="True" VerticalAlignment="Center" Margin="0,20,0,0">
<AppBarButton Icon="Find" Label="Search">
<AppBarButton.Flyout>

View File

@@ -1,10 +1,13 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage.Streams;
using Windows.UI.Core;
using Windows.UI.Popups;
using ModernKeePass.Common;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common;
using ModernKeePass.ViewModels;
// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229
@@ -15,13 +18,14 @@ namespace ModernKeePass.Pages
/// A page that displays an overview of a single group, including a preview of the items
/// within the group.
/// </summary>
public sealed partial class GroupDetailPage : Page
public sealed partial class GroupDetailPage
{
/// <summary>
/// NavigationHelper is used on each page to aid in navigation and
/// process lifetime management
/// </summary>
public NavigationHelper NavigationHelper { get; }
public GroupVm Model => (GroupVm)DataContext;
public GroupDetailPage()
{
@@ -60,6 +64,10 @@ namespace ModernKeePass.Pages
if (!(e.Parameter is GroupVm)) return;
DataContext = (GroupVm) e.Parameter;
if (Model.IsEditMode)
Task.Factory.StartNew(
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
() => TitleTextBox.Focus(FocusState.Programmatic)));
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -74,33 +82,36 @@ namespace ModernKeePass.Pages
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LeftListView.SelectedIndex == 0)
GroupVm group;
switch (LeftListView.SelectedIndex)
{
var currentGroup = DataContext as GroupVm;
currentGroup?.CreateNewGroup();
LeftListView.SelectedIndex = -1;
// TODO: Navigate to new group?
return;
case -1:
return;
case 0:
group = Model.CreateNewGroup();
break;
default:
group = LeftListView.SelectedItem as GroupVm;
break;
}
var selectedItem = LeftListView.SelectedItem as GroupVm;
if (selectedItem == null) return;
Frame.Navigate(typeof(GroupDetailPage), selectedItem);
Frame.Navigate(typeof(GroupDetailPage), group);
}
private void entries_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
EntryVm entry;
switch (GridView.SelectedIndex)
{
case -1:
return;
case 0:
var currentGroup = DataContext as GroupVm;
currentGroup?.CreateNewEntry();
GridView.SelectedIndex = -1;
// TODO: Navigate to new entry?
return;
entry = Model.CreateNewEntry();
break;
default:
entry = GridView.SelectedItem as EntryVm;
break;
}
Frame.Navigate(typeof(EntryDetailPage), GridView.SelectedItem as EntryVm);
Frame.Navigate(typeof(EntryDetailPage), entry);
}
private async void DeleteButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
@@ -111,8 +122,7 @@ namespace ModernKeePass.Pages
// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
messageDialog.Commands.Add(new UICommand("Delete", delete =>
{
var group = DataContext as GroupVm;
group?.RemoveGroup();
Model.RemoveGroup();
if (Frame.CanGoBack) Frame.GoBack();
}));
messageDialog.Commands.Add(new UICommand("Cancel"));
@@ -129,6 +139,7 @@ namespace ModernKeePass.Pages
private void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
{
// We need to synchronize the two lists (zoomed-in and zoomed-out) because the source is different
if (e.IsSourceZoomedInView == false)
{
e.DestinationItem.Item = e.SourceItem.Item;
@@ -137,9 +148,8 @@ namespace ModernKeePass.Pages
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
{
var viewModel = DataContext as GroupVm;
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx://Assets/Logo.scale-80.png"));
var results = viewModel.Entries.Skip(1).Where(e => e.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
var results = Model.Entries.Skip(1).Where(e => e.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
foreach (var result in results)
{
args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Title, result.ParentGroup.Name, result.Id, imageUri, string.Empty);
@@ -148,8 +158,7 @@ namespace ModernKeePass.Pages
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
{
var viewModel = DataContext as GroupVm;
var entry = viewModel.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
var entry = Model.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
Frame.Navigate(typeof(EntryDetailPage), entry);
}

View File

@@ -4,7 +4,7 @@
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:controls="using:ModernKeePass.Controls"
xmlns:local="using:ModernKeePass.Controls"
xmlns:converters="using:ModernKeePass.Converters"
xmlns:viewModels="using:ModernKeePass.ViewModels"
mc:Ignorable="d">
@@ -17,7 +17,8 @@
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton Content="Create new..." Click="ButtonBase_OnClick" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30">Create a new password database to the location of your chosing.</TextBlock>
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
<controls:OpenDatabaseUserControl CreateNew="True" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
<local:OpenDatabaseUserControl HorizontalAlignment="Left" CreateNew="True" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
</StackPanel>
</Page>

View File

@@ -14,10 +14,12 @@ namespace ModernKeePass.Pages
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class NewDatabasePage : Page
public sealed partial class NewDatabasePage
{
private Frame _mainFrame;
public OpenVm Model => (OpenVm)DataContext;
public NewDatabasePage()
{
InitializeComponent();
@@ -40,8 +42,7 @@ namespace ModernKeePass.Pages
var file = await savePicker.PickSaveFileAsync();
if (file == null) return;
var viewModel = DataContext as OpenVm;
viewModel.OpenFile(file);
Model.OpenFile(file);
}
private void PasswordUserControl_PasswordChecked(object sender, PasswordEventArgs e)

View File

@@ -17,7 +17,9 @@
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton Content="Browse files..." Click="ButtonBase_OnClick" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30">Open an existing password database from your PC.</TextBlock>
<HyperlinkButton Content="From Url..." IsEnabled="False" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30">Open an existing password database from an Internet location (not yet implemented).</TextBlock>
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
<local:OpenDatabaseUserControl HorizontalAlignment="Left" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
</StackPanel>

View File

@@ -1,11 +1,8 @@
using System;
using Windows.Storage.Pickers;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common;
using ModernKeePass.Events;
using ModernKeePass.ViewModels;
@@ -16,10 +13,12 @@ namespace ModernKeePass.Pages
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class OpenDatabasePage : Page
public sealed partial class OpenDatabasePage
{
private Frame _mainFrame;
public OpenVm Model => (OpenVm)DataContext;
public OpenDatabasePage()
{
InitializeComponent();
@@ -41,9 +40,8 @@ namespace ModernKeePass.Pages
};
picker.FileTypeFilter.Add(".kdbx");
var viewModel = DataContext as OpenVm;
// Application now has read/write access to the picked file
viewModel.OpenFile(await picker.PickSingleFileAsync());
Model.OpenFile(await picker.PickSingleFileAsync());
}
private void PasswordUserControl_PasswordChecked(object sender, PasswordEventArgs e)

View File

@@ -12,10 +12,12 @@ namespace ModernKeePass.Pages
/// <summary>
/// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
/// </summary>
public sealed partial class RecentDatabasesPage : Page
public sealed partial class RecentDatabasesPage
{
private Frame _mainFrame;
public RecentVm Model => (RecentVm)DataContext;
public RecentDatabasesPage()
{
InitializeComponent();
@@ -34,10 +36,8 @@ namespace ModernKeePass.Pages
private void OpenDatabaseUserControl_OnValidationChecking(object sender, EventArgs e)
{
//throw new NotImplementedException();
var viewModel = DataContext as RecentVm;
var app = (App)Application.Current;
app.Database.DatabaseFile = viewModel.SelectedItem.DatabaseFile;
app.Database.DatabaseFile = Model.SelectedItem.DatabaseFile;
}
}
}

View File

@@ -11,7 +11,9 @@
</Page.DataContext>
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton x:Name="SaveButton" Content="Save and close" Click="SaveButton_OnClick" VerticalAlignment="Top" IsEnabled="{Binding IsSaveEnabled}" />
<HyperlinkButton x:Name="SaveAsButton" Content="Save as..." Click="SaveAsButton_OnClick" VerticalAlignment="Top" IsEnabled="{Binding IsSaveEnabled}" />
<HyperlinkButton Content="Save and close" Click="SaveButton_OnClick" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30">This will save and close the currently opened database.</TextBlock>
<HyperlinkButton Content="Save as..." Click="SaveAsButton_OnClick" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30">This will save the currently opened database as a new file and leave it open.</TextBlock>
</StackPanel>
</Page>

View File

@@ -13,9 +13,10 @@ namespace ModernKeePass.Pages
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SaveDatabasePage : Page
public sealed partial class SaveDatabasePage
{
private Frame _mainFrame;
public SaveVm Model => (SaveVm)DataContext;
public SaveDatabasePage()
{
InitializeComponent();
@@ -29,8 +30,7 @@ namespace ModernKeePass.Pages
private void SaveButton_OnClick(object sender, RoutedEventArgs e)
{
var viewModel = DataContext as SaveVm;
viewModel.Save();
Model.Save();
_mainFrame.Navigate(typeof(MainPage));
}
@@ -45,8 +45,7 @@ namespace ModernKeePass.Pages
var file = await savePicker.PickSaveFileAsync();
if (file == null) return;
var viewModel = DataContext as SaveVm;
viewModel.Save(file);
Model.Save(file);
_mainFrame.Navigate(typeof(MainPage));
}

View File

@@ -0,0 +1,20 @@
<Page
x:Class="ModernKeePass.Pages.WelcomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d">
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Style="{StaticResource HeaderTextBlockStyle}" Margin="0,-20,0,0">Welcome</TextBlock>
<StackPanel Orientation="Horizontal" Margin="0,20,0,10">
<SymbolIcon Symbol="Back" Margin="-30,7,40,0" />
<TextBlock Style="{StaticResource SubheaderTextBlockStyle}">Have an existing password database? Open it here.</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<SymbolIcon Symbol="Back" Margin="-30,7,40,0" />
<TextBlock Style="{StaticResource SubheaderTextBlockStyle}">Want to create a new password database? Do it here.</TextBlock>
</StackPanel>
</StackPanel>
</Page>

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ModernKeePass.Pages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class WelcomePage : Page
{
public WelcomePage()
{
this.InitializeComponent();
}
}
}

View File

@@ -24,6 +24,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: ComVisible(false)]

View File

@@ -1,4 +1,4 @@
using Windows.UI.Text;
using System.ComponentModel;
using Windows.UI.Xaml.Controls;
using ModernKeePass.Common;
using ModernKeePass.Mappings;
@@ -7,13 +7,14 @@ using ModernKeePassLib.Security;
namespace ModernKeePass.ViewModels
{
public class EntryVm: NotifyPropertyChangedBase
public class EntryVm : INotifyPropertyChanged
{
public GroupVm ParentGroup { get; }
public PwEntry Entry { get; }
public System.Drawing.Color? BackgroundColor => Entry?.BackgroundColor;
public System.Drawing.Color? ForegroundColor => Entry?.ForegroundColor;
public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password);
public string Title
{
@@ -35,7 +36,11 @@ namespace ModernKeePass.ViewModels
public string Password
{
get { return GetEntryValue(PwDefs.PasswordField); }
set { SetEntryValue(PwDefs.PasswordField, value); }
set
{
SetEntryValue(PwDefs.PasswordField, value);
NotifyPropertyChanged("Password");
}
}
public string Url
{
@@ -61,17 +66,31 @@ namespace ModernKeePass.ViewModels
public bool IsEditMode
{
get { return _isEditMode; }
set { SetProperty(ref _isEditMode, value); }
set
{
_isEditMode = value;
NotifyPropertyChanged("IsEditMode");
}
}
public bool IsRevealPassword
{
get { return _isRevealPassword; }
set { SetProperty(ref _isRevealPassword, value); }
set
{
_isRevealPassword = value;
NotifyPropertyChanged("IsRevealPassword");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private bool _isEditMode;
private bool _isRevealPassword;
private void NotifyPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public EntryVm() { }
public EntryVm(PwEntry entry, GroupVm parent)

View File

@@ -76,18 +76,22 @@ namespace ModernKeePass.ViewModels
Groups.Insert(0, new GroupVm ());
}
public void CreateNewGroup()
public GroupVm CreateNewGroup()
{
var pwGroup = new PwGroup(true, true, "New group", PwIcon.Folder);
var pwGroup = new PwGroup(true, true, string.Empty, PwIcon.Folder);
_pwGroup.AddGroup(pwGroup, true);
Groups.Add(new GroupVm(pwGroup, this));
var newGroup = new GroupVm(pwGroup, this) {IsEditMode = true};
Groups.Add(newGroup);
return newGroup;
}
public void CreateNewEntry()
public EntryVm CreateNewEntry()
{
var pwEntry = new PwEntry(true, true);
_pwGroup.AddEntry(pwEntry, true);
Entries.Add(new EntryVm(pwEntry, this));
var newEntry = new EntryVm(pwEntry, this) {IsEditMode = true};
Entries.Add(newEntry);
return newEntry;
}
public void RemoveGroup()

View File

@@ -7,21 +7,16 @@ namespace ModernKeePass.ViewModels
{
public class MainMenuItemVm: NotifyPropertyChangedBase, IIsEnabled
{
private string _title;
private bool _isSelected;
public string Title
{
get { return IsEnabled ? _title : _title + " - Coming soon"; }
set { _title = value; }
}
public string Title { get; set; }
public Type PageType { get; set; }
public object Parameter { get; set; }
public Frame Destination { get; set; }
public int Group { get; set; } = 0;
public Symbol SymbolIcon { get; set; }
public bool IsEnabled => PageType != null;
public bool IsEnabled { get; set; } = true;
public bool IsSelected
{

View File

@@ -18,7 +18,7 @@ namespace ModernKeePass.ViewModels
public StorageFile DatabaseFile { get; private set; }
public string Token { get; private set; }
public string Name { get; private set; }
public string Name { get; private set; } = "Recent file";
public string Path => DatabaseFile.Path;
public bool IsSelected

View File

@@ -45,6 +45,7 @@ namespace ModernKeePass.ViewModels
{
var app = (App)Application.Current;
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
var isDatabaseOpen = app.Database != null && app.Database.Status == DatabaseHelper.DatabaseStatus.Opened;
var mainMenuItems = new ObservableCollection<MainMenuItemVm>
{
@@ -60,11 +61,11 @@ namespace ModernKeePass.ViewModels
new MainMenuItemVm
{
Title = "Save" , PageType = typeof(SaveDatabasePage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Save,
IsSelected = app.Database != null && app.Database.Status == DatabaseHelper.DatabaseStatus.Opened
IsSelected = isDatabaseOpen, IsEnabled = isDatabaseOpen
},
new MainMenuItemVm {
Title = "Recent" , PageType = typeof(RecentDatabasesPage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Copy,
IsSelected = (app.Database == null || app.Database.Status == DatabaseHelper.DatabaseStatus.Closed) && mru.Entries.Count > 0
IsSelected = (app.Database == null || app.Database.Status == DatabaseHelper.DatabaseStatus.Closed) && mru.Entries.Count > 0, IsEnabled = mru.Entries.Count > 0
}
};
// Auto-select the Recent Items menu item if the conditions are met

View File

@@ -1,34 +1,16 @@
using System.ComponentModel;
using Windows.Storage;
using Windows.Storage;
using Windows.UI.Xaml;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels
{
public class SaveVm: INotifyPropertyChanged
public class SaveVm
{
public bool IsSaveEnabled
{
get
{
var app = (App)Application.Current;
return app.Database.Status == DatabaseHelper.DatabaseStatus.Opened;
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void Save(bool close = true)
{
var app = (App)Application.Current;
app.Database.Save();
if (!close) return;
app.Database.Close();
NotifyPropertyChanged("IsSaveEnabled");
}
internal void Save(StorageFile file)