mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Sorting now works for entries (not yet for groups)
This commit is contained in:
@@ -394,11 +394,11 @@
|
||||
</AppBarButton>
|
||||
</CommandBar.SecondaryCommands>
|
||||
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<!--<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</interactivity:Interaction.Behaviors>-->
|
||||
</AppBarToggleButton>
|
||||
<AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ParentGroup.IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
|
@@ -44,18 +44,31 @@
|
||||
</AppBarButton>
|
||||
</CommandBar.SecondaryCommands>
|
||||
<AppBarButton Icon="Sort" Label="Sort" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:CallMethodAction MethodName="SortEntries" TargetObject="{Binding}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem x:Uid="AppBarSortEntries">
|
||||
<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>
|
||||
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<!--<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</interactivity:Interaction.Behaviors>-->
|
||||
</AppBarToggleButton>
|
||||
<AppBarButton Icon="Undo" Label="Restore" Visibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Click="RestoreButton_Click">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
|
@@ -132,6 +132,12 @@
|
||||
<data name="AboutHomepage.Text" xml:space="preserve">
|
||||
<value>Homepage:</value>
|
||||
</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">
|
||||
<value>Create new key file</value>
|
||||
</data>
|
||||
|
@@ -183,12 +183,26 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public void SortEntries()
|
||||
{
|
||||
var comparer = new PwEntryComparer(PwDefs.TitleField, true, true);
|
||||
var comparer = new PwEntryComparer(PwDefs.TitleField, true, false);
|
||||
try
|
||||
{
|
||||
// TODO: this throws an exception
|
||||
_pwGroup.Entries.Sort(comparer);
|
||||
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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user