Sorting now works for entries (not yet for groups)

This commit is contained in:
BONNEVILLE Geoffroy
2017-11-30 11:05:47 +01:00
parent f2731c49dd
commit 33223934e3
7 changed files with 48 additions and 17 deletions

View File

@@ -394,11 +394,11 @@
</AppBarButton> </AppBarButton>
</CommandBar.SecondaryCommands> </CommandBar.SecondaryCommands>
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}"> <AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}">
<interactivity:Interaction.Behaviors> <!--<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click"> <core:EventTriggerBehavior EventName="Click">
<core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" /> <core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" />
</core:EventTriggerBehavior> </core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>-->
</AppBarToggleButton> </AppBarToggleButton>
<AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ParentGroup.IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click"> <AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ParentGroup.IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click">
<interactivity:Interaction.Behaviors> <interactivity:Interaction.Behaviors>

View File

@@ -44,18 +44,31 @@
</AppBarButton> </AppBarButton>
</CommandBar.SecondaryCommands> </CommandBar.SecondaryCommands>
<AppBarButton Icon="Sort" Label="Sort" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"> <AppBarButton Icon="Sort" Label="Sort" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
<interactivity:Interaction.Behaviors> <Button.Flyout>
<core:EventTriggerBehavior EventName="Click"> <MenuFlyout>
<core:CallMethodAction MethodName="SortEntries" TargetObject="{Binding}" /> <MenuFlyoutItem x:Uid="AppBarSortEntries">
</core:EventTriggerBehavior> <interactivity:Interaction.Behaviors>
</interactivity:Interaction.Behaviors> <core:EventTriggerBehavior EventName="Click">
<core:CallMethodAction MethodName="SortEntries" TargetObject="{Binding}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</MenuFlyoutItem>
<MenuFlyoutItem x:Uid="AppBarSortGroups">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:CallMethodAction MethodName="SortGroups" TargetObject="{Binding}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</MenuFlyoutItem>
</MenuFlyout>
</Button.Flyout>
</AppBarButton> </AppBarButton>
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}"> <AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}">
<interactivity:Interaction.Behaviors> <!--<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click"> <core:EventTriggerBehavior EventName="Click">
<core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" /> <core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" />
</core:EventTriggerBehavior> </core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>-->
</AppBarToggleButton> </AppBarToggleButton>
<AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click"> <AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click">
<interactivity:Interaction.Behaviors> <interactivity:Interaction.Behaviors>

View File

@@ -132,6 +132,12 @@
<data name="AboutHomepage.Text" xml:space="preserve"> <data name="AboutHomepage.Text" xml:space="preserve">
<value>Homepage:</value> <value>Homepage:</value>
</data> </data>
<data name="AppBarSortEntries.Text" xml:space="preserve">
<value>Entries</value>
</data>
<data name="AppBarSortGroups.Text" xml:space="preserve">
<value>Groups</value>
</data>
<data name="CompositeKeyNewKeyFileTooltip.Content" xml:space="preserve"> <data name="CompositeKeyNewKeyFileTooltip.Content" xml:space="preserve">
<value>Create new key file</value> <value>Create new key file</value>
</data> </data>

View File

@@ -183,12 +183,26 @@ namespace ModernKeePass.ViewModels
public void SortEntries() public void SortEntries()
{ {
var comparer = new PwEntryComparer(PwDefs.TitleField, true, true); var comparer = new PwEntryComparer(PwDefs.TitleField, true, false);
try try
{ {
// TODO: this throws an exception
_pwGroup.Entries.Sort(comparer); _pwGroup.Entries.Sort(comparer);
Entries = new ObservableCollection<EntryVm>(Entries.OrderBy(e => e.Name)); Entries = new ObservableCollection<EntryVm>(Entries.OrderBy(e => e.Name));
OnPropertyChanged("Entries");
}
catch (Exception e)
{
MessageDialogService.ShowErrorDialog(e);
}
}
public void SortGroups()
{
try
{
_pwGroup.SortSubGroups(false);
Groups = new ObservableCollection<GroupVm>(Groups.Skip(1).OrderBy(g => g.Name));
OnPropertyChanged("Groups");
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -97,7 +97,7 @@ namespace ModernKeePassApp.Test
Assert.AreEqual(1, firstGroup.Count()); Assert.AreEqual(1, firstGroup.Count());
Assert.IsNotNull(settingsVm.SelectedItem); Assert.IsNotNull(settingsVm.SelectedItem);
var selectedItem = (ListMenuItemVm) settingsVm.SelectedItem; var selectedItem = (ListMenuItemVm) settingsVm.SelectedItem;
Assert.AreEqual("General", selectedItem.Title); Assert.AreEqual("New", selectedItem.Title);
} }
} }
} }

View File

@@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>ModernKeePassLib</id> <id>ModernKeePassLib</id>
<version>2.37.7000</version> <version>2.37.8000</version>
<title>ModernKeePassLib</title> <title>ModernKeePassLib</title>
<authors>Geoffroy Bonneville</authors> <authors>Geoffroy Bonneville</authors>
<owners>Geoffroy Bonneville</owners> <owners>Geoffroy Bonneville</owners>
@@ -10,7 +10,7 @@
<projectUrl>https://github.com/wismna/ModernKeePass</projectUrl> <projectUrl>https://github.com/wismna/ModernKeePass</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</description> <description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</description>
<releaseNotes>Can now create key files</releaseNotes> <releaseNotes>Code cleanup</releaseNotes>
<copyright>Copyright © 2017 Geoffroy Bonneville</copyright> <copyright>Copyright © 2017 Geoffroy Bonneville</copyright>
<tags>KeePass KeePassLib Portable PCL NetStandard</tags> <tags>KeePass KeePassLib Portable PCL NetStandard</tags>
<dependencies> <dependencies>

View File

@@ -18,9 +18,7 @@ namespace ModernKeePassLib.Native
internal static class NativeMethods internal static class NativeMethods
{ {
public static bool SupportsStrCmpNaturally { public static bool SupportsStrCmpNaturally => false;
get { throw new NotImplementedException(); }
}
internal const int GCRY_CIPHER_AES256 = 9; internal const int GCRY_CIPHER_AES256 = 9;
internal const int GCRY_CIPHER_MODE_ECB = 1; internal const int GCRY_CIPHER_MODE_ECB = 1;