mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Move finally works
Sort entries and groups refresh page info Stopped using breadcrumb user control - for now Some refactoring
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using MediatR;
|
using System.Linq;
|
||||||
|
using MediatR;
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Group.Models;
|
using ModernKeePass.Application.Group.Models;
|
||||||
using ModernKeePass.Domain.Exceptions;
|
using ModernKeePass.Domain.Exceptions;
|
||||||
@@ -23,6 +24,7 @@ namespace ModernKeePass.Application.Group.Commands.SortEntries
|
|||||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||||
|
|
||||||
_database.SortEntries(message.Group.Id);
|
_database.SortEntries(message.Group.Id);
|
||||||
|
message.Group.Entries = message.Group.Entries.OrderBy(e => e.Title).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
using MediatR;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using MediatR;
|
||||||
using ModernKeePass.Application.Common.Interfaces;
|
using ModernKeePass.Application.Common.Interfaces;
|
||||||
using ModernKeePass.Application.Group.Models;
|
using ModernKeePass.Application.Group.Models;
|
||||||
using ModernKeePass.Domain.Exceptions;
|
using ModernKeePass.Domain.Exceptions;
|
||||||
@@ -23,6 +25,7 @@ namespace ModernKeePass.Application.Group.Commands.SortGroups
|
|||||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||||
|
|
||||||
_database.SortSubGroups(message.Group.Id);
|
_database.SortSubGroups(message.Group.Id);
|
||||||
|
message.Group.SubGroups = message.Group.SubGroups.OrderBy(g => g.Title).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,9 @@
|
|||||||
<Setter Property="Foreground" Value="{ThemeResource SearchBoxForegroundThemeBrush}" />
|
<Setter Property="Foreground" Value="{ThemeResource SearchBoxForegroundThemeBrush}" />
|
||||||
<Setter Property="Padding" Value="{ThemeResource SearchBoxThemePadding}"/>
|
<Setter Property="Padding" Value="{ThemeResource SearchBoxThemePadding}"/>
|
||||||
<Setter Property="IsTabStop" Value="False" />
|
<Setter Property="IsTabStop" Value="False" />
|
||||||
|
<Setter Property="Width" Value="350" />
|
||||||
|
<Setter Property="Height" Value="32" />
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||||
<Setter Property="Typography.StylisticSet20" Value="True"/>
|
<Setter Property="Typography.StylisticSet20" Value="True"/>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
|
@@ -27,7 +27,9 @@ using ModernKeePass.Application.Security.Commands.GeneratePassword;
|
|||||||
using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity;
|
using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity;
|
||||||
using ModernKeePass.Domain.Enums;
|
using ModernKeePass.Domain.Enums;
|
||||||
using ModernKeePass.Application.Group.Models;
|
using ModernKeePass.Application.Group.Models;
|
||||||
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Extensions;
|
using ModernKeePass.Extensions;
|
||||||
|
using ModernKeePass.Models;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
@@ -45,8 +47,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
public bool SpecialPatternSelected { get; set; }
|
public bool SpecialPatternSelected { get; set; }
|
||||||
public bool BracketsPatternSelected { get; set; }
|
public bool BracketsPatternSelected { get; set; }
|
||||||
public string CustomChars { get; set; } = string.Empty;
|
public string CustomChars { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Id => SelectedItem.Id;
|
public string Id => SelectedItem.Id;
|
||||||
|
|
||||||
|
public string ParentGroupName => _parent.Title;
|
||||||
|
|
||||||
public bool IsRecycleOnDelete
|
public bool IsRecycleOnDelete
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -221,6 +226,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
public RelayCommand RestoreCommand { get; }
|
public RelayCommand RestoreCommand { get; }
|
||||||
public RelayCommand DeleteCommand { get; }
|
public RelayCommand DeleteCommand { get; }
|
||||||
public RelayCommand GoBackCommand { get; }
|
public RelayCommand GoBackCommand { get; }
|
||||||
|
public RelayCommand GoToParentCommand { get; set; }
|
||||||
|
|
||||||
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
@@ -251,6 +257,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
RestoreCommand = new RelayCommand(async () => await RestoreHistory());
|
RestoreCommand = new RelayCommand(async () => await RestoreHistory());
|
||||||
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
||||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||||
|
GoToParentCommand = new RelayCommand(() => GoToGroup(_parent.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Initialize(string entryId)
|
public async Task Initialize(string entryId)
|
||||||
@@ -323,6 +330,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
await _mediator.Send(new AddEntryCommand { ParentGroupId = destination, EntryId = Id });
|
await _mediator.Send(new AddEntryCommand { ParentGroupId = destination, EntryId = Id });
|
||||||
await _mediator.Send(new RemoveEntryCommand { ParentGroupId = _parent.Id, EntryId = Id });
|
await _mediator.Send(new RemoveEntryCommand { ParentGroupId = _parent.Id, EntryId = Id });
|
||||||
|
GoToGroup(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetFieldValue(string fieldName, object value)
|
public async Task SetFieldValue(string fieldName, object value)
|
||||||
@@ -363,5 +371,10 @@ namespace ModernKeePass.ViewModels
|
|||||||
});
|
});
|
||||||
_navigation.GoBack();
|
_navigation.GoBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GoToGroup(string groupId)
|
||||||
|
{
|
||||||
|
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = groupId });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -79,12 +79,12 @@ namespace ModernKeePass.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ParentGroupName => _parent?.Title;
|
||||||
|
|
||||||
public bool IsRecycleOnDelete => Database.IsRecycleBinEnabled && !IsInRecycleBin;
|
public bool IsRecycleOnDelete => Database.IsRecycleBinEnabled && !IsInRecycleBin;
|
||||||
|
|
||||||
public bool IsInRecycleBin => _parent != null && _parent.Id == Database.RecycleBinId;
|
public bool IsInRecycleBin => _parent != null && _parent.Id == Database.RecycleBinId;
|
||||||
|
|
||||||
public IEnumerable<GroupVm> BreadCrumb { get; private set; }
|
|
||||||
|
|
||||||
public RelayCommand SaveCommand { get; }
|
public RelayCommand SaveCommand { get; }
|
||||||
public RelayCommand SortEntriesCommand { get; }
|
public RelayCommand SortEntriesCommand { get; }
|
||||||
public RelayCommand SortGroupsCommand { get; }
|
public RelayCommand SortGroupsCommand { get; }
|
||||||
@@ -93,6 +93,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
public RelayCommand CreateGroupCommand { get; }
|
public RelayCommand CreateGroupCommand { get; }
|
||||||
public RelayCommand DeleteCommand { get; set; }
|
public RelayCommand DeleteCommand { get; set; }
|
||||||
public RelayCommand GoBackCommand { get; set; }
|
public RelayCommand GoBackCommand { get; set; }
|
||||||
|
public RelayCommand GoToParentCommand { get; set; }
|
||||||
|
|
||||||
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
@@ -122,6 +123,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
CreateGroupCommand = new RelayCommand(async () => await AddNewGroup(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
CreateGroupCommand = new RelayCommand(async () => await AddNewGroup(), () => !IsInRecycleBin && Database.RecycleBinId != Id);
|
||||||
DeleteCommand = new RelayCommand(async () => await AskForDelete(),() => IsNotRoot);
|
DeleteCommand = new RelayCommand(async () => await AskForDelete(),() => IsNotRoot);
|
||||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||||
|
GoToParentCommand= new RelayCommand(() => GoToGroup(_parent.Id), () => _parent != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Initialize(string groupId)
|
public async Task Initialize(string groupId)
|
||||||
@@ -130,7 +132,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
||||||
{
|
{
|
||||||
_parent = await _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId });
|
_parent = await _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId });
|
||||||
BreadCrumb = new List<GroupVm> { _parent };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
||||||
@@ -146,11 +147,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
IsNew = isNew
|
IsNew = isNew
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void GoToGroup(string entryId, bool isNew = false)
|
public void GoToGroup(string groupId, bool isNew = false)
|
||||||
{
|
{
|
||||||
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem
|
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem
|
||||||
{
|
{
|
||||||
Id = entryId,
|
Id = groupId,
|
||||||
IsNew = isNew
|
IsNew = isNew
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -171,6 +172,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
await _mediator.Send(new AddGroupCommand {ParentGroupId = destinationId, GroupId = Id });
|
await _mediator.Send(new AddGroupCommand {ParentGroupId = destinationId, GroupId = Id });
|
||||||
await _mediator.Send(new RemoveGroupCommand {ParentGroupId = _parent.Id, GroupId = Id });
|
await _mediator.Send(new RemoveGroupCommand {ParentGroupId = _parent.Id, GroupId = Id });
|
||||||
|
GoToGroup(destinationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<EntryVm>> Search(string queryText)
|
public async Task<IEnumerable<EntryVm>> Search(string queryText)
|
||||||
@@ -210,6 +212,8 @@ namespace ModernKeePass.ViewModels
|
|||||||
private async Task SortEntriesAsync()
|
private async Task SortEntriesAsync()
|
||||||
{
|
{
|
||||||
await _mediator.Send(new SortEntriesCommand {Group = _group});
|
await _mediator.Send(new SortEntriesCommand {Group = _group});
|
||||||
|
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
||||||
|
Entries.CollectionChanged += Entries_CollectionChanged;
|
||||||
RaisePropertyChanged(nameof(Entries));
|
RaisePropertyChanged(nameof(Entries));
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
}
|
}
|
||||||
@@ -217,6 +221,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
private async Task SortGroupsAsync()
|
private async Task SortGroupsAsync()
|
||||||
{
|
{
|
||||||
await _mediator.Send(new SortGroupsCommand {Group = _group});
|
await _mediator.Send(new SortGroupsCommand {Group = _group});
|
||||||
|
Groups = new ObservableCollection<GroupVm>(_group.SubGroups);
|
||||||
RaisePropertyChanged(nameof(Groups));
|
RaisePropertyChanged(nameof(Groups));
|
||||||
SaveCommand.RaiseCanExecuteChanged();
|
SaveCommand.RaiseCanExecuteChanged();
|
||||||
}
|
}
|
||||||
|
@@ -402,14 +402,9 @@
|
|||||||
<Setter Property="Margin" Value="0,20,0,0"/>
|
<Setter Property="Margin" Value="0,20,0,0"/>
|
||||||
<Setter Property="FontSize" Value="18"/>
|
<Setter Property="FontSize" Value="18"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style BasedOn="{StaticResource TextBoxWithButtonStyle}" TargetType="local:TextBoxWithButton" x:Key="EntryTextBoxWithButtonStyle">
|
|
||||||
<Setter Property="Width" Value="350"/>
|
|
||||||
<Setter Property="Height" Value="32"/>
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
|
||||||
</Style>
|
|
||||||
</StackPanel.Resources>
|
</StackPanel.Resources>
|
||||||
<TextBlock x:Uid="EntryLogin" />
|
<TextBlock x:Uid="EntryLogin" />
|
||||||
<local:TextBoxWithButton x:Uid="LoginTextBox" Text="{Binding UserName, Mode=TwoWay}" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="" IsEnabled="{Binding IsCurrentEntry}">
|
<local:TextBoxWithButton x:Uid="LoginTextBox" Text="{Binding UserName, Mode=TwoWay}" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="" IsEnabled="{Binding IsCurrentEntry}">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||||
<actions:ClipboardAction Text="{Binding UserName}" />
|
<actions:ClipboardAction Text="{Binding UserName}" />
|
||||||
@@ -419,7 +414,7 @@
|
|||||||
</local:TextBoxWithButton>
|
</local:TextBoxWithButton>
|
||||||
<TextBlock x:Uid="EntryPassword" />
|
<TextBlock x:Uid="EntryPassword" />
|
||||||
<PasswordBox HorizontalAlignment="Left" Password="{Binding Password, Mode=TwoWay}" Width="350" Height="32" IsPasswordRevealButtonEnabled="True" Visibility="{Binding IsRevealPassword, Converter={StaticResource InverseBooleanToVisibilityConverter}}" Style="{StaticResource PasswordBoxWithButtonStyle}" IsEnabled="{Binding IsCurrentEntry}" />
|
<PasswordBox HorizontalAlignment="Left" Password="{Binding Password, Mode=TwoWay}" Width="350" Height="32" IsPasswordRevealButtonEnabled="True" Visibility="{Binding IsRevealPassword, Converter={StaticResource InverseBooleanToVisibilityConverter}}" Style="{StaticResource PasswordBoxWithButtonStyle}" IsEnabled="{Binding IsCurrentEntry}" />
|
||||||
<local:TextBoxWithButton x:Uid="PasswordTextBox" Text="{Binding Password, Mode=TwoWay}" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="" IsEnabled="{Binding IsCurrentEntry}">
|
<local:TextBoxWithButton x:Uid="PasswordTextBox" Text="{Binding Password, Mode=TwoWay}" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="" IsEnabled="{Binding IsCurrentEntry}">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||||
<actions:ClipboardAction Text="{Binding Password}" />
|
<actions:ClipboardAction Text="{Binding Password}" />
|
||||||
@@ -430,7 +425,7 @@
|
|||||||
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="350" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroundBrushComplexityConverter}}" />
|
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="350" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroundBrushComplexityConverter}}" />
|
||||||
<CheckBox x:Uid="EntryShowPassword" HorizontalAlignment="Left" Margin="-3,0,0,0" IsChecked="{Binding IsRevealPassword, Mode=TwoWay}" IsEnabled="{Binding IsRevealPasswordEnabled}" />
|
<CheckBox x:Uid="EntryShowPassword" HorizontalAlignment="Left" Margin="-3,0,0,0" IsChecked="{Binding IsRevealPassword, Mode=TwoWay}" IsEnabled="{Binding IsRevealPasswordEnabled}" />
|
||||||
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
|
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
|
||||||
<local:TextBoxWithButton x:Uid="UrlTextBox" Text="{Binding Url, Mode=TwoWay}" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="" IsEnabled="{Binding IsCurrentEntry}">
|
<local:TextBoxWithButton x:Uid="UrlTextBox" Text="{Binding Url, Mode=TwoWay}" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="" IsEnabled="{Binding IsCurrentEntry}">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||||
<actions:NavigateToUrlAction Url="{Binding Url}" />
|
<actions:NavigateToUrlAction Url="{Binding Url}" />
|
||||||
@@ -524,7 +519,12 @@
|
|||||||
</core:DataTriggerBehavior>
|
</core:DataTriggerBehavior>
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
<userControls:BreadCrumbUserControl Grid.Column="1" Grid.Row="1" ItemsSource="{Binding BreadCrumb}" Margin="5,-5,0,0" />
|
<HyperlinkButton Grid.Column="1" Grid.Row="1"
|
||||||
|
FontWeight="Light" FontSize="12" Padding="0" Margin="5,-5,0,0"
|
||||||
|
Foreground="{StaticResource MainColor}"
|
||||||
|
Content="{Binding ParentGroupName}"
|
||||||
|
Style="{StaticResource MainColorHyperlinkButton}"
|
||||||
|
Command="{Binding GoToParentCommand}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<userControls:TopMenuUserControl
|
<userControls:TopMenuUserControl
|
||||||
x:Name="TopMenu" Grid.Column="2"
|
x:Name="TopMenu" Grid.Column="2"
|
||||||
|
@@ -236,12 +236,16 @@
|
|||||||
</core:DataTriggerBehavior>
|
</core:DataTriggerBehavior>
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
<userControls:BreadCrumbUserControl Grid.Column="1" Grid.Row="1" ItemsSource="{Binding BreadCrumb}" Margin="5,-5,0,0" />
|
<HyperlinkButton Grid.Column="1" Grid.Row="1"
|
||||||
|
FontWeight="Light" FontSize="12" Padding="0" Margin="5,-5,0,0"
|
||||||
|
Foreground="{StaticResource MainColor}"
|
||||||
|
Content="{Binding ParentGroupName}"
|
||||||
|
Style="{StaticResource MainColorHyperlinkButton}"
|
||||||
|
Command="{Binding GoToParentCommand}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="2"
|
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="2"
|
||||||
SortButtonVisibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"
|
SortButtonVisibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||||
IsEditButtonChecked="{Binding IsEditMode, Mode=TwoWay}"
|
IsEditButtonChecked="{Binding IsEditMode, Mode=TwoWay}"
|
||||||
IsDeleteButtonEnabled="{Binding IsNotRoot}"
|
|
||||||
SaveCommand="{Binding SaveCommand}"
|
SaveCommand="{Binding SaveCommand}"
|
||||||
MoveCommand="{Binding MoveCommand}"
|
MoveCommand="{Binding MoveCommand}"
|
||||||
SortEntriesCommand="{Binding SortEntriesCommand}"
|
SortEntriesCommand="{Binding SortEntriesCommand}"
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" DataContext="{StaticResource ViewModel}">
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
<StackPanel.Resources>
|
<StackPanel.Resources>
|
||||||
<CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
|
<CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
|
||||||
<CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
|
<CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
|
||||||
|
@@ -16,7 +16,11 @@
|
|||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.Resources>
|
<ItemsControl.Resources>
|
||||||
<DataTemplate x:Name="FirstItemTemplate">
|
<DataTemplate x:Name="FirstItemTemplate">
|
||||||
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Title}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
|
<HyperlinkButton
|
||||||
|
FontWeight="Light" FontSize="12" Padding="0"
|
||||||
|
Foreground="{StaticResource MainColor}"
|
||||||
|
Content="{Binding Title}"
|
||||||
|
Style="{StaticResource MainColorHyperlinkButton}">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="Click">
|
<core:EventTriggerBehavior EventName="Click">
|
||||||
<core:NavigateToPageAction Parameter="{Binding Id}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
|
<core:NavigateToPageAction Parameter="{Binding Id}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
|
||||||
|
@@ -56,10 +56,9 @@
|
|||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
</SymbolIcon>
|
</SymbolIcon>
|
||||||
<Button.Flyout>
|
<Button.Flyout>
|
||||||
<Flyout>
|
<Flyout Opening="MoveButtonFlyout_OnOpening">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<SearchBox
|
<SearchBox x:Uid="GroupsSearch"
|
||||||
x:Uid="GroupsSearch"
|
|
||||||
Padding="12" Width="350"
|
Padding="12" Width="350"
|
||||||
Margin="0,5,0,5"
|
Margin="0,5,0,5"
|
||||||
FontSize="15"
|
FontSize="15"
|
||||||
@@ -68,7 +67,7 @@
|
|||||||
SearchHistoryEnabled="False"
|
SearchHistoryEnabled="False"
|
||||||
Style="{StaticResource MainColorSearchBox}">
|
Style="{StaticResource MainColorSearchBox}">
|
||||||
</SearchBox>
|
</SearchBox>
|
||||||
<Button x:Uid="MoveButton" Command="{Binding MoveCommand, ElementName=UserControl}" CommandParameter="{Binding SelectedDestinationGroup}" Style="{StaticResource MainColorButton}" />
|
<Button x:Name="MoveButton" x:Uid="MoveButton" Style="{StaticResource MainColorButton}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Flyout>
|
</Flyout>
|
||||||
</Button.Flyout>
|
</Button.Flyout>
|
||||||
@@ -100,7 +99,7 @@
|
|||||||
</ToolTipService.ToolTip>
|
</ToolTipService.ToolTip>
|
||||||
</SymbolIcon>
|
</SymbolIcon>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource MenuButtonStyle}">
|
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" Style="{StaticResource MenuButtonStyle}">
|
||||||
<SymbolIcon Symbol="Delete">
|
<SymbolIcon Symbol="Delete">
|
||||||
<ToolTipService.ToolTip>
|
<ToolTipService.ToolTip>
|
||||||
<ToolTip x:Uid="TopMenuDeleteButton" />
|
<ToolTip x:Uid="TopMenuDeleteButton" />
|
||||||
@@ -112,13 +111,13 @@
|
|||||||
<SymbolIcon Symbol="More" />
|
<SymbolIcon Symbol="More" />
|
||||||
<Button.Flyout>
|
<Button.Flyout>
|
||||||
<MenuFlyout Opening="OverflowFlyout_OnOpening">
|
<MenuFlyout Opening="OverflowFlyout_OnOpening">
|
||||||
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" x:Name="SaveFlyout" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuMoveFlyout" x:Name="MoveFlyout" Visibility="{Binding MoveButtonVisibility, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuMoveFlyout" x:Name="MoveFlyout" Visibility="{Binding MoveButtonVisibility, ElementName=UserControl}" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
|
||||||
<ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" />
|
<ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Click="DeleteButton_Click" />
|
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||||
<MenuFlyoutItem x:Uid="TopMenuSortGroupsFlyout" x:Name="SortGroupsFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
<MenuFlyoutItem x:Uid="TopMenuSortGroupsFlyout" x:Name="SortGroupsFlyout" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</Button.Flyout>
|
</Button.Flyout>
|
||||||
</Button>
|
</Button>
|
||||||
|
@@ -135,18 +135,6 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
typeof(TopMenuUserControl),
|
typeof(TopMenuUserControl),
|
||||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||||
|
|
||||||
public bool IsDeleteButtonEnabled
|
|
||||||
{
|
|
||||||
get { return (bool)GetValue(IsDeleteButtonEnabledProperty); }
|
|
||||||
set { SetValue(IsDeleteButtonEnabledProperty, value); }
|
|
||||||
}
|
|
||||||
public static readonly DependencyProperty IsDeleteButtonEnabledProperty =
|
|
||||||
DependencyProperty.Register(
|
|
||||||
nameof(IsDeleteButtonEnabled),
|
|
||||||
typeof(bool),
|
|
||||||
typeof(TopMenuUserControl),
|
|
||||||
new PropertyMetadata(true, (o, args) => { }));
|
|
||||||
|
|
||||||
public bool IsEditButtonChecked
|
public bool IsEditButtonChecked
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsEditButtonCheckedProperty); }
|
get { return (bool)GetValue(IsEditButtonCheckedProperty); }
|
||||||
@@ -160,7 +148,6 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
new PropertyMetadata(false, (o, args) => { }));
|
new PropertyMetadata(false, (o, args) => { }));
|
||||||
|
|
||||||
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
||||||
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
|
|
||||||
|
|
||||||
public TopMenuUserControl()
|
public TopMenuUserControl()
|
||||||
{
|
{
|
||||||
@@ -179,27 +166,28 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
EditButtonClick?.Invoke(sender, e);
|
EditButtonClick?.Invoke(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
DeleteButtonClick?.Invoke(sender, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OverflowFlyout_OnOpening(object sender, object e)
|
private void OverflowFlyout_OnOpening(object sender, object e)
|
||||||
{
|
{
|
||||||
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
|
|
||||||
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
|
|
||||||
|
|
||||||
EditFlyout.IsChecked = IsEditButtonChecked;
|
EditFlyout.IsChecked = IsEditButtonChecked;
|
||||||
|
|
||||||
MoveFlyout.Visibility = MoveButtonVisibility;
|
MoveFlyout.Visibility = MoveButtonVisibility;
|
||||||
RestoreFlyout.Visibility = RestoreButtonVisibility;
|
RestoreFlyout.Visibility = RestoreButtonVisibility;
|
||||||
|
|
||||||
SortEntriesFlyout.Visibility = SortButtonVisibility;
|
SortEntriesFlyout.Visibility = SortButtonVisibility;
|
||||||
SortGroupsFlyout.Visibility = SortButtonVisibility;
|
SortGroupsFlyout.Visibility = SortButtonVisibility;
|
||||||
|
|
||||||
|
SaveFlyout.Command = SaveCommand;
|
||||||
|
DeleteFlyout.Command = DeleteCommand;
|
||||||
|
RestoreFlyout.Command = RestoreCommand;
|
||||||
SortEntriesFlyout.Command = SortEntriesCommand;
|
SortEntriesFlyout.Command = SortEntriesCommand;
|
||||||
SortGroupsFlyout.Command = SortGroupsCommand;
|
SortGroupsFlyout.Command = SortGroupsCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These are somehow necessary as otherwise, the command is not bound
|
||||||
|
private void MoveButtonFlyout_OnOpening(object sender, object e)
|
||||||
|
{
|
||||||
|
MoveButton.Command = MoveCommand;
|
||||||
|
}
|
||||||
|
|
||||||
private void SortFlyout_OnOpening(object sender, object e)
|
private void SortFlyout_OnOpening(object sender, object e)
|
||||||
{
|
{
|
||||||
SortEntriesButtonFlyout.Command = SortEntriesCommand;
|
SortEntriesButtonFlyout.Command = SortEntriesCommand;
|
||||||
@@ -209,15 +197,21 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
|
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
|
||||||
{
|
{
|
||||||
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appdata://Assets/ModernKeePass-SmallLogo.scale-80.png"));
|
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appdata://Assets/ModernKeePass-SmallLogo.scale-80.png"));
|
||||||
foreach (var group in Model.Groups.Where(g => g.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0))
|
var groups = Model.Groups.Where(g => g.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
|
||||||
|
foreach (var group in groups)
|
||||||
{
|
{
|
||||||
args.Request.SearchSuggestionCollection.AppendResultSuggestion(group.Title, group.ParentGroupName, group.Id, imageUri, string.Empty);
|
args.Request.SearchSuggestionCollection.AppendResultSuggestion(
|
||||||
|
group.Title,
|
||||||
|
group.ParentGroupName,
|
||||||
|
group.Id,
|
||||||
|
imageUri,
|
||||||
|
string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
|
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
|
||||||
{
|
{
|
||||||
Model.SelectedDestinationGroup = args.Tag;
|
MoveButton.CommandParameter = args.Tag;
|
||||||
MoveCommand.RaiseCanExecuteChanged();
|
MoveCommand.RaiseCanExecuteChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
WinAppCommon/ViewModels/UserControls/BreadcrumbVm.cs
Normal file
19
WinAppCommon/ViewModels/UserControls/BreadcrumbVm.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
using GalaSoft.MvvmLight.Views;
|
||||||
|
using ModernKeePass.Common;
|
||||||
|
using ModernKeePass.Models;
|
||||||
|
|
||||||
|
namespace ModernKeePass.ViewModels
|
||||||
|
{
|
||||||
|
public class BreadcrumbVm
|
||||||
|
{
|
||||||
|
public RelayCommand<string> NavigateCommand { get; }
|
||||||
|
|
||||||
|
public BreadcrumbVm(INavigationService navigation)
|
||||||
|
{
|
||||||
|
NavigateCommand = new RelayCommand<string>(groupId =>
|
||||||
|
navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem {Id = groupId}),
|
||||||
|
groupId => !string.IsNullOrEmpty(groupId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
public class TopMenuVm
|
public class TopMenuVm
|
||||||
{
|
{
|
||||||
public IEnumerable<GroupVm> Groups { get; set; }
|
public IEnumerable<GroupVm> Groups { get; set; }
|
||||||
public string SelectedDestinationGroup { get; set; }
|
|
||||||
|
|
||||||
public TopMenuVm(IMediator mediator)
|
public TopMenuVm(IMediator mediator)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user