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 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.2.0.14_Test\ModernKeePass_1.2.0.14_AnyCPU.appxsym 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.2.0.14_scale-140.appx 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.2.0.14_scale-180.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> </UserControl.Resources>
<StackPanel> <StackPanel>
<PasswordBox x:Name="PasswordBox" Width="300" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" Style="{StaticResource PasswordBoxWithButtonStyle}"/> <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" /> <TextBlock x:Name="StatusTextBlock" Height="32" Width="auto" Foreground="#FFBF6969" FontSize="16" FontWeight="Bold" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

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

View File

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

View File

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

View File

@@ -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.2.0.14" /> <Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.3.0.17" />
<Properties> <Properties>
<DisplayName>ModernKeePass</DisplayName> <DisplayName>ModernKeePass</DisplayName>
<PublisherDisplayName>wismna</PublisherDisplayName> <PublisherDisplayName>wismna</PublisherDisplayName>
@@ -15,7 +15,7 @@
</Resources> </Resources>
<Applications> <Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="ModernKeePass.App"> <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 Square310x310Logo="Assets\Square310x310Logo.png" Wide310x150Logo="Assets\Wide310x150Logo.png" Square70x70Logo="Assets\Square70x70Logo.png">
</m2:DefaultTile> </m2:DefaultTile>
<m2:SplashScreen Image="Assets\ModernKeePass-SplashScreen.png" /> <m2:SplashScreen Image="Assets\ModernKeePass-SplashScreen.png" />

View File

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

View File

@@ -1,9 +1,11 @@
using System; using System;
using System.Threading.Tasks;
using Windows.UI.Core;
using Windows.UI.Popups; using Windows.UI.Popups;
using ModernKeePass.Common;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common;
using ModernKeePass.ViewModels; 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 // 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 /// 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. /// consulter les autres éléments qui appartiennent au même groupe.
/// </summary> /// </summary>
public sealed partial class EntryDetailPage : Page public sealed partial class EntryDetailPage
{ {
private NavigationHelper navigationHelper; private NavigationHelper navigationHelper;
public EntryVm Model => (EntryVm) DataContext;
/// <summary> /// <summary>
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et /// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
/// gestion de la durée de vie des processus /// gestion de la durée de vie des processus
@@ -58,10 +62,12 @@ namespace ModernKeePass.Pages
protected override void OnNavigatedTo(NavigationEventArgs e) protected override void OnNavigatedTo(NavigationEventArgs e)
{ {
navigationHelper.OnNavigatedTo(e); navigationHelper.OnNavigatedTo(e);
if (e.Parameter is EntryVm) if (!(e.Parameter is EntryVm)) return;
{ DataContext = (EntryVm)e.Parameter;
DataContext = e.Parameter as EntryVm; if (Model.IsEditMode)
} Task.Factory.StartNew(
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
() => TitleTextBox.Focus(FocusState.Programmatic)));
} }
protected override void OnNavigatedFrom(NavigationEventArgs e) protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -99,7 +105,7 @@ namespace ModernKeePass.Pages
{ {
try try
{ {
var uri = new Uri(urlTextBox.Text); var uri = new Uri(UrlTextBox.Text);
await Windows.System.Launcher.LaunchUriAsync(uri); await Windows.System.Launcher.LaunchUriAsync(uri);
} }
catch catch

View File

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

View File

@@ -1,10 +1,13 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Windows.Storage.Streams; using Windows.Storage.Streams;
using Windows.UI.Core;
using Windows.UI.Popups; using Windows.UI.Popups;
using ModernKeePass.Common; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common;
using ModernKeePass.ViewModels; using ModernKeePass.ViewModels;
// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229 // 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 /// A page that displays an overview of a single group, including a preview of the items
/// within the group. /// within the group.
/// </summary> /// </summary>
public sealed partial class GroupDetailPage : Page public sealed partial class GroupDetailPage
{ {
/// <summary> /// <summary>
/// NavigationHelper is used on each page to aid in navigation and /// NavigationHelper is used on each page to aid in navigation and
/// process lifetime management /// process lifetime management
/// </summary> /// </summary>
public NavigationHelper NavigationHelper { get; } public NavigationHelper NavigationHelper { get; }
public GroupVm Model => (GroupVm)DataContext;
public GroupDetailPage() public GroupDetailPage()
{ {
@@ -60,6 +64,10 @@ namespace ModernKeePass.Pages
if (!(e.Parameter is GroupVm)) return; if (!(e.Parameter is GroupVm)) return;
DataContext = (GroupVm) e.Parameter; DataContext = (GroupVm) e.Parameter;
if (Model.IsEditMode)
Task.Factory.StartNew(
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
() => TitleTextBox.Focus(FocusState.Programmatic)));
} }
protected override void OnNavigatedFrom(NavigationEventArgs e) protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -74,33 +82,36 @@ namespace ModernKeePass.Pages
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e) private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (LeftListView.SelectedIndex == 0) GroupVm group;
switch (LeftListView.SelectedIndex)
{ {
var currentGroup = DataContext as GroupVm; case -1:
currentGroup?.CreateNewGroup(); return;
LeftListView.SelectedIndex = -1; case 0:
// TODO: Navigate to new group? group = Model.CreateNewGroup();
return; break;
default:
group = LeftListView.SelectedItem as GroupVm;
break;
} }
var selectedItem = LeftListView.SelectedItem as GroupVm; Frame.Navigate(typeof(GroupDetailPage), group);
if (selectedItem == null) return;
Frame.Navigate(typeof(GroupDetailPage), selectedItem);
} }
private void entries_SelectionChanged(object sender, SelectionChangedEventArgs e) private void entries_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
EntryVm entry;
switch (GridView.SelectedIndex) switch (GridView.SelectedIndex)
{ {
case -1: case -1:
return; return;
case 0: case 0:
var currentGroup = DataContext as GroupVm; entry = Model.CreateNewEntry();
currentGroup?.CreateNewEntry(); break;
GridView.SelectedIndex = -1; default:
// TODO: Navigate to new entry? entry = GridView.SelectedItem as EntryVm;
return; 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) 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 // 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 => messageDialog.Commands.Add(new UICommand("Delete", delete =>
{ {
var group = DataContext as GroupVm; Model.RemoveGroup();
group?.RemoveGroup();
if (Frame.CanGoBack) Frame.GoBack(); if (Frame.CanGoBack) Frame.GoBack();
})); }));
messageDialog.Commands.Add(new UICommand("Cancel")); messageDialog.Commands.Add(new UICommand("Cancel"));
@@ -129,6 +139,7 @@ namespace ModernKeePass.Pages
private void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e) 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) if (e.IsSourceZoomedInView == false)
{ {
e.DestinationItem.Item = e.SourceItem.Item; e.DestinationItem.Item = e.SourceItem.Item;
@@ -137,9 +148,8 @@ namespace ModernKeePass.Pages
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args) 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 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) foreach (var result in results)
{ {
args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Title, result.ParentGroup.Name, result.Id, imageUri, string.Empty); 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) private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
{ {
var viewModel = DataContext as GroupVm; var entry = Model.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
var entry = viewModel.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
Frame.Navigate(typeof(EntryDetailPage), entry); Frame.Navigate(typeof(EntryDetailPage), entry);
} }

View File

@@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:ModernKeePass.Controls" xmlns:local="using:ModernKeePass.Controls"
xmlns:converters="using:ModernKeePass.Converters" xmlns:converters="using:ModernKeePass.Converters"
xmlns:viewModels="using:ModernKeePass.ViewModels" xmlns:viewModels="using:ModernKeePass.ViewModels"
mc:Ignorable="d"> mc:Ignorable="d">
@@ -17,7 +17,8 @@
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton Content="Create new..." Click="ButtonBase_OnClick" /> <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" /> <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> </StackPanel>
</Page> </Page>

View File

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

View File

@@ -17,7 +17,9 @@
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton Content="Browse files..." Click="ButtonBase_OnClick" /> <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" /> <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" /> <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" /> <local:OpenDatabaseUserControl HorizontalAlignment="Left" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
</StackPanel> </StackPanel>

View File

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

View File

@@ -12,10 +12,12 @@ namespace ModernKeePass.Pages
/// <summary> /// <summary>
/// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame. /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
/// </summary> /// </summary>
public sealed partial class RecentDatabasesPage : Page public sealed partial class RecentDatabasesPage
{ {
private Frame _mainFrame; private Frame _mainFrame;
public RecentVm Model => (RecentVm)DataContext;
public RecentDatabasesPage() public RecentDatabasesPage()
{ {
InitializeComponent(); InitializeComponent();
@@ -34,10 +36,8 @@ namespace ModernKeePass.Pages
private void OpenDatabaseUserControl_OnValidationChecking(object sender, EventArgs e) private void OpenDatabaseUserControl_OnValidationChecking(object sender, EventArgs e)
{ {
//throw new NotImplementedException();
var viewModel = DataContext as RecentVm;
var app = (App)Application.Current; 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> </Page.DataContext>
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton x:Name="SaveButton" Content="Save and close" Click="SaveButton_OnClick" VerticalAlignment="Top" IsEnabled="{Binding IsSaveEnabled}" /> <HyperlinkButton Content="Save and close" Click="SaveButton_OnClick" />
<HyperlinkButton x:Name="SaveAsButton" Content="Save as..." Click="SaveAsButton_OnClick" VerticalAlignment="Top" IsEnabled="{Binding IsSaveEnabled}" /> <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> </StackPanel>
</Page> </Page>

View File

@@ -13,9 +13,10 @@ namespace ModernKeePass.Pages
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// An empty page that can be used on its own or navigated to within a Frame.
/// </summary> /// </summary>
public sealed partial class SaveDatabasePage : Page public sealed partial class SaveDatabasePage
{ {
private Frame _mainFrame; private Frame _mainFrame;
public SaveVm Model => (SaveVm)DataContext;
public SaveDatabasePage() public SaveDatabasePage()
{ {
InitializeComponent(); InitializeComponent();
@@ -29,8 +30,7 @@ namespace ModernKeePass.Pages
private void SaveButton_OnClick(object sender, RoutedEventArgs e) private void SaveButton_OnClick(object sender, RoutedEventArgs e)
{ {
var viewModel = DataContext as SaveVm; Model.Save();
viewModel.Save();
_mainFrame.Navigate(typeof(MainPage)); _mainFrame.Navigate(typeof(MainPage));
} }
@@ -45,8 +45,7 @@ namespace ModernKeePass.Pages
var file = await savePicker.PickSaveFileAsync(); var file = await savePicker.PickSaveFileAsync();
if (file == null) return; if (file == null) return;
var viewModel = DataContext as SaveVm; Model.Save(file);
viewModel.Save(file);
_mainFrame.Navigate(typeof(MainPage)); _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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")] [assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View File

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

View File

@@ -76,18 +76,22 @@ namespace ModernKeePass.ViewModels
Groups.Insert(0, new GroupVm ()); 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); _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); var pwEntry = new PwEntry(true, true);
_pwGroup.AddEntry(pwEntry, 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() public void RemoveGroup()

View File

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

View File

@@ -18,7 +18,7 @@ namespace ModernKeePass.ViewModels
public StorageFile DatabaseFile { get; private set; } public StorageFile DatabaseFile { get; private set; }
public string Token { 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 string Path => DatabaseFile.Path;
public bool IsSelected public bool IsSelected

View File

@@ -45,6 +45,7 @@ namespace ModernKeePass.ViewModels
{ {
var app = (App)Application.Current; var app = (App)Application.Current;
var mru = StorageApplicationPermissions.MostRecentlyUsedList; var mru = StorageApplicationPermissions.MostRecentlyUsedList;
var isDatabaseOpen = app.Database != null && app.Database.Status == DatabaseHelper.DatabaseStatus.Opened;
var mainMenuItems = new ObservableCollection<MainMenuItemVm> var mainMenuItems = new ObservableCollection<MainMenuItemVm>
{ {
@@ -60,11 +61,11 @@ namespace ModernKeePass.ViewModels
new MainMenuItemVm new MainMenuItemVm
{ {
Title = "Save" , PageType = typeof(SaveDatabasePage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Save, 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 { new MainMenuItemVm {
Title = "Recent" , PageType = typeof(RecentDatabasesPage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Copy, 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 // 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 Windows.UI.Xaml;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels 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) public void Save(bool close = true)
{ {
var app = (App)Application.Current; var app = (App)Application.Current;
app.Database.Save(); app.Database.Save();
if (!close) return; if (!close) return;
app.Database.Close(); app.Database.Close();
NotifyPropertyChanged("IsSaveEnabled");
} }
internal void Save(StorageFile file) internal void Save(StorageFile file)