mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 07:30:15 -04:00
Removed Breadcrumb service
Breadcrumb control handles breadcrumb status Layout improvements Added the ability to delete an entry from the group menu
This commit is contained in:
@@ -86,7 +86,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Common\Behaviors\DirtyStatusBehavior.cs" />
|
||||
<Compile Include="Common\Interfaces\IBreadcrumbService.cs" />
|
||||
<Compile Include="Common\Interfaces\ICryptographyClient.cs" />
|
||||
<Compile Include="Common\Interfaces\IDatabaseSettingsProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\IDatabaseProxy.cs" />
|
||||
@@ -101,7 +100,6 @@
|
||||
<Compile Include="Common\Mappings\IMapFrom.cs" />
|
||||
<Compile Include="Common\Mappings\MappingProfile.cs" />
|
||||
<Compile Include="Common\Models\BreadcrumbItem.cs" />
|
||||
<Compile Include="Common\Services\BreadcrumbService.cs" />
|
||||
<Compile Include="Entry\Commands\AddAttachment\AddAttachmentCommand.cs" />
|
||||
<Compile Include="Entry\Commands\AddHistory\AddHistoryCommand.cs" />
|
||||
<Compile Include="Entry\Commands\DeleteAttachment\DeleteAttachmentCommand.cs" />
|
||||
|
@@ -1,12 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.Application.Common.Models;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IBreadcrumbService
|
||||
{
|
||||
void Push(BreadcrumbItem item);
|
||||
BreadcrumbItem Pop(int count = 1);
|
||||
IEnumerable<BreadcrumbItem> GetItems();
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Common.Models;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Services
|
||||
{
|
||||
public class BreadcrumbService: IBreadcrumbService
|
||||
{
|
||||
private readonly Stack<BreadcrumbItem> _breadcrumb;
|
||||
|
||||
public BreadcrumbService()
|
||||
{
|
||||
_breadcrumb = new Stack<BreadcrumbItem>();
|
||||
}
|
||||
|
||||
public void Push(BreadcrumbItem item)
|
||||
{
|
||||
_breadcrumb.Push(item);
|
||||
}
|
||||
|
||||
public BreadcrumbItem Pop(int count = 1)
|
||||
{
|
||||
if (_breadcrumb.Count == 0) return null;
|
||||
for (var i = 1; i < count; i++)
|
||||
{
|
||||
_breadcrumb.Pop();
|
||||
}
|
||||
|
||||
return _breadcrumb.Pop();
|
||||
}
|
||||
|
||||
public IEnumerable<BreadcrumbItem> GetItems()
|
||||
{
|
||||
return _breadcrumb;
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,8 +2,6 @@
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Behaviors;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Common.Services;
|
||||
|
||||
namespace ModernKeePass.Application
|
||||
{
|
||||
@@ -15,7 +13,6 @@ namespace ModernKeePass.Application
|
||||
services.AddMediatR(assembly);
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(DirtyStatusBehavior<,>));
|
||||
|
||||
services.AddSingleton(typeof(IBreadcrumbService), typeof(BreadcrumbService));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
@@ -44,12 +44,14 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public string Id => _current.Id;
|
||||
|
||||
public GroupVm Parent { get; private set; }
|
||||
|
||||
public bool IsRecycleOnDelete
|
||||
{
|
||||
get
|
||||
{
|
||||
var database = Database;
|
||||
return database.IsRecycleBinEnabled && _parent.Id != database.RecycleBinId;
|
||||
return database.IsRecycleBinEnabled && Parent.Id != database.RecycleBinId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +226,6 @@ namespace ModernKeePass.ViewModels
|
||||
private readonly IFileProxy _file;
|
||||
private readonly ICryptographyClient _cryptography;
|
||||
private readonly IDateTime _dateTime;
|
||||
private GroupVm _parent;
|
||||
private EntryVm _current;
|
||||
private int _selectedIndex;
|
||||
private int _additionalFieldSelectedIndex = -1;
|
||||
@@ -242,7 +243,7 @@ namespace ModernKeePass.ViewModels
|
||||
_dateTime = dateTime;
|
||||
|
||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||
MoveCommand = new RelayCommand<string>(async destination => await Move(destination), destination => _parent != null && !string.IsNullOrEmpty(destination) && destination != _parent.Id);
|
||||
MoveCommand = new RelayCommand<string>(async destination => await Move(destination), destination => Parent != null && !string.IsNullOrEmpty(destination) && destination != Parent.Id);
|
||||
RestoreCommand = new RelayCommand(async () => await RestoreHistory());
|
||||
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
||||
AddAdditionalField = new RelayCommand(AddField, () => IsCurrentEntry);
|
||||
@@ -263,7 +264,7 @@ namespace ModernKeePass.ViewModels
|
||||
SelectedIndex = 0;
|
||||
_current = await _mediator.Send(new GetEntryQuery { Id = entryId });
|
||||
SetCurrentEntry(_current);
|
||||
_parent = await _mediator.Send(new GetGroupQuery { Id = _current.ParentGroupId });
|
||||
Parent = await _mediator.Send(new GetGroupQuery { Id = _current.ParentGroupId });
|
||||
History = new ObservableCollection<IEntityVm> { _current };
|
||||
foreach (var entry in _current.History.Skip(1))
|
||||
{
|
||||
@@ -289,7 +290,7 @@ namespace ModernKeePass.ViewModels
|
||||
private async Task Move(string destination)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@ using GalaSoft.MvvmLight.Views;
|
||||
using MediatR;
|
||||
using Messages;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Common.Models;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
@@ -44,6 +43,8 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public bool IsNotRoot => Database.RootGroupId != _group.Id;
|
||||
|
||||
public GroupVm Parent { get; private set; }
|
||||
|
||||
public IOrderedEnumerable<IGrouping<char, EntryVm>> EntriesZoomedOut => from e in Entries
|
||||
group e by (e.Title.Value ?? string.Empty).ToUpper().FirstOrDefault() into grp
|
||||
orderby grp.Key
|
||||
@@ -82,11 +83,11 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string ParentGroupName => _parent == null ? Database.Name : _parent.Title;
|
||||
public string ParentGroupName => Parent == null ? Database.Name : Parent.Title;
|
||||
|
||||
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 RelayCommand SaveCommand { get; }
|
||||
public RelayCommand SortEntriesCommand { get; }
|
||||
@@ -108,21 +109,18 @@ namespace ModernKeePass.ViewModels
|
||||
private readonly INavigationService _navigation;
|
||||
private readonly IDialogService _dialog;
|
||||
private readonly INotificationService _notification;
|
||||
private readonly IBreadcrumbService _breadcrumb;
|
||||
private GroupVm _group;
|
||||
private GroupVm _parent;
|
||||
private bool _isEditMode;
|
||||
private EntryVm _reorderedEntry;
|
||||
private GroupVm _reorderedGroup;
|
||||
|
||||
public GroupDetailVm(IMediator mediator, IResourceProxy resource, INavigationService navigation, IDialogService dialog, INotificationService notification, IBreadcrumbService breadcrumb)
|
||||
public GroupDetailVm(IMediator mediator, IResourceProxy resource, INavigationService navigation, IDialogService dialog, INotificationService notification)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_resource = resource;
|
||||
_navigation = navigation;
|
||||
_dialog = dialog;
|
||||
_notification = notification;
|
||||
_breadcrumb = breadcrumb;
|
||||
|
||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||
SortEntriesCommand = new RelayCommand(async () => await SortEntriesAsync(), () => IsEditMode);
|
||||
@@ -132,7 +130,7 @@ namespace ModernKeePass.ViewModels
|
||||
CreateGroupCommand = new RelayCommand<string>(async newGroupName => await AddNewGroup(newGroupName), _ => !IsInRecycleBin && Database.RecycleBinId != Id);
|
||||
DeleteCommand = new RelayCommand(async () => await AskForDelete(),() => IsNotRoot);
|
||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||
GoToParentCommand = new RelayCommand(() => GoToGroup(_parent.Id), () => _parent != null);
|
||||
GoToParentCommand = new RelayCommand(() => GoToGroup(Parent.Id), () => Parent != null);
|
||||
GoToGroupCommand = new RelayCommand<GroupVm>(group => GoToGroup(group.Id), group => group != null);
|
||||
GoToEntryCommand = new RelayCommand<EntryVm>(entry => GoToEntry(entry.Id), entry => entry != null);
|
||||
DeleteEntryCommand = new RelayCommand<EntryVm>(async entry => await AskForDeleteEntry(entry), entry => entry != null);
|
||||
@@ -140,43 +138,14 @@ namespace ModernKeePass.ViewModels
|
||||
MessengerInstance.Register<DatabaseSavedMessage>(this, _ => SaveCommand.RaiseCanExecuteChanged());
|
||||
}
|
||||
|
||||
private async Task AskForDeleteEntry(EntryVm entry)
|
||||
{
|
||||
if (IsRecycleOnDelete)
|
||||
{
|
||||
await DeleteEntry(entry.Id);
|
||||
_notification.Show(_resource.GetResourceValue("EntityDeleting"), string.Format(_resource.GetResourceValue("EntryRecycled"), entry.Title));
|
||||
}
|
||||
else
|
||||
{
|
||||
await _dialog.ShowMessage(
|
||||
string.Format(_resource.GetResourceValue("EntryDeletingConfirmation"), entry.Title),
|
||||
_resource.GetResourceValue("EntityDeleting"),
|
||||
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||
_resource.GetResourceValue("EntityDeleteCancelButton"),
|
||||
async isOk =>
|
||||
{
|
||||
if (isOk) await DeleteEntry(entry.Id);
|
||||
});
|
||||
}
|
||||
}
|
||||
private async Task DeleteEntry(string entryId)
|
||||
{
|
||||
await _mediator.Send(new DeleteEntryCommand
|
||||
{
|
||||
EntryId = entryId,
|
||||
ParentGroupId = Id,
|
||||
RecycleBinName = _resource.GetResourceValue("RecycleBinTitle")
|
||||
});
|
||||
}
|
||||
|
||||
public async Task Initialize(string groupId)
|
||||
{
|
||||
_group = await _mediator.Send(new GetGroupQuery { Id = groupId });
|
||||
if (!string.IsNullOrEmpty(_group.ParentGroupId))
|
||||
{
|
||||
_parent = await _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId });
|
||||
Parent = await _mediator.Send(new GetGroupQuery {Id = _group.ParentGroupId});
|
||||
}
|
||||
else Parent = null;
|
||||
|
||||
Entries = new ObservableCollection<EntryVm>(_group.Entries);
|
||||
Entries.CollectionChanged += Entries_CollectionChanged;
|
||||
@@ -186,7 +155,6 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public void GoToEntry(string entryId, bool isNew = false)
|
||||
{
|
||||
_breadcrumb.Push(new BreadcrumbItem { Name = Title, Path = Id, Icon = _group.Icon });
|
||||
_navigation.NavigateTo(Constants.Navigation.EntryPage, new NavigationItem
|
||||
{
|
||||
Id = entryId,
|
||||
@@ -195,7 +163,6 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
public void GoToGroup(string groupId, bool isNew = false)
|
||||
{
|
||||
_breadcrumb.Push(new BreadcrumbItem { Name = Title, Path = Id, Icon = _group.Icon });
|
||||
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem
|
||||
{
|
||||
Id = groupId,
|
||||
@@ -218,7 +185,7 @@ namespace ModernKeePass.ViewModels
|
||||
public async Task Move(string destinationId)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -328,8 +295,38 @@ namespace ModernKeePass.ViewModels
|
||||
RecycleBinName = _resource.GetResourceValue("RecycleBinTitle")
|
||||
});
|
||||
|
||||
_breadcrumb.Pop();
|
||||
_navigation.GoBack();
|
||||
}
|
||||
|
||||
private async Task AskForDeleteEntry(EntryVm entry)
|
||||
{
|
||||
if (IsRecycleOnDelete)
|
||||
{
|
||||
await DeleteEntry(entry);
|
||||
_notification.Show(_resource.GetResourceValue("EntityDeleting"), string.Format(_resource.GetResourceValue("EntryRecycled"), entry.Title));
|
||||
}
|
||||
else
|
||||
{
|
||||
await _dialog.ShowMessage(
|
||||
string.Format(_resource.GetResourceValue("EntryDeletingConfirmation"), entry.Title),
|
||||
_resource.GetResourceValue("EntityDeleting"),
|
||||
_resource.GetResourceValue("EntityDeleteActionButton"),
|
||||
_resource.GetResourceValue("EntityDeleteCancelButton"),
|
||||
async isOk =>
|
||||
{
|
||||
if (isOk) await DeleteEntry(entry);
|
||||
});
|
||||
}
|
||||
}
|
||||
private async Task DeleteEntry(EntryVm entry)
|
||||
{
|
||||
await _mediator.Send(new DeleteEntryCommand
|
||||
{
|
||||
EntryId = entry.Id,
|
||||
ParentGroupId = Id,
|
||||
RecycleBinName = _resource.GetResourceValue("RecycleBinTitle")
|
||||
});
|
||||
Entries.Remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -232,7 +232,7 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<controls:BreadcrumbUserControl x:Name="Breadcrumb" />
|
||||
<controls:BreadcrumbUserControl x:Name="Breadcrumb" Group="{Binding Parent}" />
|
||||
<controls:TopMenuUserControl
|
||||
x:Name="TopMenu" Grid.Column="2"
|
||||
MoveButtonVisibility="{Binding IsCurrentEntry, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
|
@@ -130,7 +130,7 @@
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</MenuFlyoutItem>
|
||||
<MenuFlyoutItem x:Uid="EntryItemDelete" Command="{Binding DeleteEntryCommand}" CommandParameter="{Binding}" />
|
||||
<MenuFlyoutItem x:Uid="EntryItemDelete" Command="{Binding DataContext.DeleteEntryCommand, ElementName=Page}" CommandParameter="{Binding}" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
@@ -189,41 +189,12 @@
|
||||
<!-- Back button and page title -->
|
||||
<Grid Grid.Row="0" Background="{ThemeResource AppBarBackgroundThemeBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{StaticResource MenuWidthGridLength}"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
Command="{Binding GoBackCommand}"
|
||||
Height="{StaticResource MenuHeight}"
|
||||
Width="{StaticResource MenuWidth}"
|
||||
AutomationProperties.Name="Back"
|
||||
AutomationProperties.AutomationId="BackButton"
|
||||
AutomationProperties.ItemType="Navigation Button"
|
||||
Style="{StaticResource NoBorderButtonStyle}">
|
||||
<SymbolIcon Symbol="Back" />
|
||||
</Button>
|
||||
<Button Grid.Column="1"
|
||||
Height="{StaticResource MenuHeight}"
|
||||
Command="{Binding GoToParentCommand}"
|
||||
Style="{StaticResource NoBorderButtonStyle}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="Up" />
|
||||
<TextBlock x:Name="UpButtonText" Margin="10,2,0,0" Text="{Binding ParentGroupName}" FontStyle="Italic" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding ParentGroupName}" />
|
||||
</ToolTipService.ToolTip>
|
||||
</Button>
|
||||
<!--<Viewbox Grid.Column="2" MaxHeight="200" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<userControls:SymbolPickerUserControl Width="100" Height="70" SelectedSymbol="{Binding Icon, Mode=TwoWay}" />
|
||||
</Viewbox>
|
||||
<Viewbox Grid.Column="2" MaxHeight="200" Visibility="{Binding IsEditMode, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<SymbolIcon Symbol="{Binding Icon}" Width="100" Height="70" />
|
||||
</Viewbox>-->
|
||||
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="4"
|
||||
<userControls:BreadcrumbUserControl x:Name="Breadcrumb" Group="{Binding Parent}" />
|
||||
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="2"
|
||||
SortButtonVisibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
EditButtonVisibility="Visible"
|
||||
IsEditButtonChecked="{Binding IsEditMode, Mode=TwoWay}"
|
||||
@@ -253,9 +224,6 @@
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SemanticZoom" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="-60,0,0,0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonText" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Medium">
|
||||
@@ -266,9 +234,6 @@
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SemanticZoom" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonText" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Large">
|
||||
@@ -282,9 +247,6 @@
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SemanticZoom" Storyboard.TargetProperty="Margin">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,0"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonText" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
@@ -53,18 +53,21 @@ namespace ModernKeePass.Views
|
||||
VisualStateManager.GoToState(this, "Small", true);
|
||||
VisualStateManager.GoToState(TopMenu, "Collapsed", true);
|
||||
VisualStateManager.GoToState(HamburgerMenu, "Hidden", true);
|
||||
VisualStateManager.GoToState(Breadcrumb, "Small", true);
|
||||
}
|
||||
else if (e.NewSize.Width > 640 && e.NewSize.Width <= 1008)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Medium", true);
|
||||
VisualStateManager.GoToState(TopMenu, "Overflowed", true);
|
||||
VisualStateManager.GoToState(HamburgerMenu, "Collapsed", true);
|
||||
VisualStateManager.GoToState(Breadcrumb, "Medium", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Large", true);
|
||||
VisualStateManager.GoToState(TopMenu, "Overflowed", true);
|
||||
VisualStateManager.GoToState(HamburgerMenu, "Expanded", true);
|
||||
VisualStateManager.GoToState(Breadcrumb, "Large", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,18 +9,19 @@
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel Orientation="Horizontal" DataContext="{Binding Source={StaticResource Locator}, Path=Breadcrumb}">
|
||||
<StackPanel x:Name="StackPanel" Orientation="Horizontal" DataContext="{Binding Source={StaticResource Locator}, Path=Breadcrumb}">
|
||||
<StackPanel.Resources>
|
||||
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
||||
<DataTemplate x:Key="FirstItemTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding Icon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=48}" Margin="0,3,0,0" />
|
||||
<TextBlock Margin="10,5,10,0" Text="{Binding Name}" FontStyle="Italic" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="OtherItemTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="Play" Margin="0" />
|
||||
<SymbolIcon Symbol="{Binding Icon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=48}" Margin="0" />
|
||||
<TextBlock Margin="10,5,10,0" Text=">" HorizontalAlignment="Center" />
|
||||
<SymbolIcon Symbol="{Binding Icon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=48}" Margin="0,3,0,0" />
|
||||
<TextBlock Margin="10,5,10,0" Text="{Binding Name}" FontStyle="Italic" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
@@ -37,17 +38,18 @@
|
||||
</Button>
|
||||
<Button
|
||||
Height="{StaticResource MenuHeight}"
|
||||
Command="{Binding GoToCommand}"
|
||||
Command="{Binding GoUpCommand}"
|
||||
Style="{StaticResource NoBorderButtonStyle}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="Up" />
|
||||
<TextBlock x:Name="UpButtonText" Margin="10,2,0,0" Text="{Binding ParentGroupName}" FontStyle="Italic" HorizontalAlignment="Center" />
|
||||
<SymbolIcon x:Name="UpButtonIcon" Symbol="{Binding ParentGroupIcon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=48}" Margin="16,0,0,0" />
|
||||
<TextBlock x:Name="UpButtonText" Margin="11,2,0,0" Text="{Binding ParentGroupName}" FontStyle="Italic" FontWeight="Normal" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding ParentGroupName}" />
|
||||
</ToolTipService.ToolTip>
|
||||
</Button>
|
||||
<ListView x:Name="ListView" ItemsSource="{Binding BreadcrumbItems}" Height="{StaticResource MenuHeight}">
|
||||
<ListView x:Name="ListView" ItemsSource="{Binding BreadcrumbItems}">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
@@ -59,6 +61,7 @@
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="Height" Value="{StaticResource MenuHeight}" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
@@ -71,6 +74,9 @@
|
||||
<VisualStateGroup x:Name="PageLayout">
|
||||
<VisualState x:Name="Small">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonIcon" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonText" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
@@ -81,6 +87,9 @@
|
||||
</VisualState>
|
||||
<VisualState x:Name="Medium">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonIcon" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonText" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
@@ -91,6 +100,9 @@
|
||||
</VisualState>
|
||||
<VisualState x:Name="Large">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonIcon" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpButtonText" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
|
@@ -1,9 +1,30 @@
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class BreadcrumbUserControl
|
||||
{
|
||||
public GroupVm Group
|
||||
{
|
||||
get { return (GroupVm)GetValue(GroupProperty); }
|
||||
set { SetValue(GroupProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty GroupProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(Group),
|
||||
typeof(GroupVm),
|
||||
typeof(BreadcrumbUserControl),
|
||||
new PropertyMetadata(null, async (o, args) =>
|
||||
{
|
||||
var userControl = o as BreadcrumbUserControl;
|
||||
var vm = userControl?.StackPanel.DataContext as BreadcrumbControlVm;
|
||||
if (vm != null) await vm.Initialize(args.NewValue as GroupVm).ConfigureAwait(false);
|
||||
}));
|
||||
|
||||
public BreadcrumbUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@@ -573,4 +573,7 @@
|
||||
<data name="ToastCopyTitle.Message" xml:space="preserve">
|
||||
<value>Title copied to clipboard</value>
|
||||
</data>
|
||||
<data name="EntryItemDelete.Text" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
</root>
|
@@ -573,4 +573,7 @@
|
||||
<data name="ToastCopyTitle.Message" xml:space="preserve">
|
||||
<value>Titre copié dans le presse-papiers</value>
|
||||
</data>
|
||||
<data name="EntryItemDelete.Text" xml:space="preserve">
|
||||
<value>Supprimer</value>
|
||||
</data>
|
||||
</root>
|
@@ -1,45 +1,62 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Models;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Models;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class BreadcrumbControlVm
|
||||
{
|
||||
public IEnumerable<BreadcrumbItem> BreadcrumbItems { get; }
|
||||
public string ParentGroupName => BreadcrumbItems.Last()?.Name;
|
||||
public ObservableCollection<BreadcrumbItem> BreadcrumbItems { get; }
|
||||
public string ParentGroupName { get; private set; }
|
||||
public Icon ParentGroupIcon { get; private set; }
|
||||
|
||||
public RelayCommand GoBackCommand { get; }
|
||||
public RelayCommand GoUpCommand { get; private set; }
|
||||
public RelayCommand<int> GoToCommand { get; }
|
||||
|
||||
private readonly IMediator _mediator;
|
||||
private readonly INavigationService _navigation;
|
||||
private readonly IBreadcrumbService _breadcrumb;
|
||||
|
||||
public BreadcrumbControlVm(INavigationService navigation, IBreadcrumbService breadcrumb)
|
||||
public BreadcrumbControlVm(IMediator mediator, INavigationService navigation)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_navigation = navigation;
|
||||
_breadcrumb = breadcrumb;
|
||||
|
||||
BreadcrumbItems = _breadcrumb.GetItems().Reverse();
|
||||
GoBackCommand = new RelayCommand(GoBack);
|
||||
BreadcrumbItems = new ObservableCollection<BreadcrumbItem>();
|
||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||
GoToCommand = new RelayCommand<int>(GoTo);
|
||||
}
|
||||
|
||||
public async Task Initialize(GroupVm group)
|
||||
{
|
||||
GoUpCommand = new RelayCommand(() => GoTo(BreadcrumbItems.Count - 1), () => group != null);
|
||||
|
||||
if (group == null) return;
|
||||
ParentGroupName = group.Title;
|
||||
ParentGroupIcon = group.Icon;
|
||||
|
||||
BreadcrumbItems.Insert(0, new BreadcrumbItem { Path = group.Id, Name = group.Title, Icon = group.Icon });
|
||||
var parentGroup = group;
|
||||
while (!string.IsNullOrEmpty(parentGroup.ParentGroupId))
|
||||
{
|
||||
parentGroup = await _mediator.Send(new GetGroupQuery {Id = parentGroup.ParentGroupId});
|
||||
BreadcrumbItems.Insert(0, new BreadcrumbItem {Path = parentGroup.Id, Name = parentGroup.Title, Icon = parentGroup.Icon});
|
||||
}
|
||||
}
|
||||
|
||||
private void GoTo(int index)
|
||||
{
|
||||
var breadcrumb = _breadcrumb.Pop(BreadcrumbItems.Count() - index);
|
||||
if (BreadcrumbItems.Count == 0) return;
|
||||
var breadcrumb = BreadcrumbItems[index];
|
||||
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = breadcrumb.Path });
|
||||
}
|
||||
|
||||
private void GoBack()
|
||||
{
|
||||
_breadcrumb.Pop();
|
||||
_navigation.GoBack();
|
||||
}
|
||||
}
|
||||
}
|
@@ -57,7 +57,6 @@ namespace ModernKeePass.ViewModels
|
||||
SimpleIoc.Default.Register(() => App.Services.GetRequiredService<INavigationService>());
|
||||
SimpleIoc.Default.Register(() => App.Services.GetRequiredService<INotificationService>());
|
||||
SimpleIoc.Default.Register(() => App.Services.GetRequiredService<ICryptographyClient>());
|
||||
SimpleIoc.Default.Register(() => App.Services.GetRequiredService<IBreadcrumbService>());
|
||||
}
|
||||
|
||||
SimpleIoc.Default.Register<SecurityVm>();
|
||||
|
Reference in New Issue
Block a user