Added the option to close DB without saving

Changed the way recent files are retrieved
Stopped showing the DB Closed exception on suspend
Reordering entries works
Moved code from infra to application
Cleanup
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-09 19:43:06 +02:00
parent 14fd4634db
commit d972b6cb5a
35 changed files with 141 additions and 100 deletions

View File

@@ -27,7 +27,7 @@ namespace ModernKeePass.Views
picker.FileTypeFilter.Add(".csv");
// Application now has read/write access to the picked file
var file = await picker.PickSingleFileAsync();
var file = await picker.PickSingleFileAsync().AsTask();
if (file == null) return;
}

View File

@@ -34,7 +34,7 @@ namespace ModernKeePass.Views
};
savePicker.FileTypeChoices.Add("KeePass 2.x database", new List<string> { ".kdbx" });
var file = await savePicker.PickSaveFileAsync();
var file = await savePicker.PickSaveFileAsync().AsTask();
if (file == null) return;
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
@@ -72,7 +72,7 @@ namespace ModernKeePass.Views
picker.FileTypeFilter.Add(Model.ImportFileExtensionFilter);
// Application now has read/write access to the picked file
Model.ImportFile = await picker.PickSingleFileAsync();
Model.ImportFile = await picker.PickSingleFileAsync().AsTask();
if (Model.ImportFile != null) ImportFileLink.Content = Model.ImportFile.Name;
}
}

View File

@@ -42,7 +42,7 @@ namespace ModernKeePass.Views
picker.FileTypeFilter.Add(".kdbx");
// Application now has read/write access to the picked file
var file = await picker.PickSingleFileAsync();
var file = await picker.PickSingleFileAsync().AsTask();
if (file == null) return;

View File

@@ -12,12 +12,10 @@
mc:Ignorable="d">
<Page.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<CollectionViewSource x:Name="RecentItemsSource" Source="{Binding RecentItems}" />
<viewModels:RecentVm x:Key="ViewModel"/>
<!--<CollectionViewSource x:Name="RecentItemsSource" Source="{Binding RecentItems}" />-->
</Page.Resources>
<Page.DataContext>
<viewModels:RecentVm/>
</Page.DataContext>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
@@ -29,7 +27,7 @@
</StackPanel>
</HyperlinkButton>
<ListView Grid.Row="1"
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
ItemsSource="{Binding RecentItems}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
<ListView.ItemTemplate>
@@ -47,8 +45,10 @@
<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />
<userControls:CompositeKeyUserControl Grid.Row="2" x:Name="DatabaseUserControl" x:Uid="CompositeKeyOpenButton" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" DatabaseFilePath="{Binding Token}">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ValidationChecked">
<core:EventTriggerBehavior EventName="ValidationChecking">
<core:CallMethodAction TargetObject="{Binding}" MethodName="UpdateAccessTime" />
</core:EventTriggerBehavior>
<core:EventTriggerBehavior EventName="ValidationChecked">
<core:NavigateToPageAction TargetPage="ModernKeePass.Views.GroupDetailPage" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>

View File

@@ -15,5 +15,7 @@
<TextBlock x:Uid="SaveDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
<HyperlinkButton x:Uid="SaveAsButton" Click="SaveAsButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<TextBlock x:Uid="SaveAsDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
<HyperlinkButton x:Uid="CloseButton" Click="CloseButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<TextBlock x:Uid="CloseDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
</StackPanel>
</Page>

View File

@@ -43,11 +43,17 @@ namespace ModernKeePass.Views
};
savePicker.FileTypeChoices.Add("KeePass 2.x database", new List<string> { ".kdbx" });
var file = await savePicker.PickSaveFileAsync();
var file = await savePicker.PickSaveFileAsync().AsTask();
if (file == null) return;
await Model.Save(file);
_mainFrame.Navigate(typeof(MainPage));
}
private async void CloseButton_OnClick(object sender, RoutedEventArgs e)
{
await Model.Close();
_mainFrame.Navigate(typeof(MainPage));
}
}
}