WIP Breadcrumb

This commit is contained in:
BONNEVILLE Geoffroy
2018-06-12 18:40:54 +02:00
parent 25945b8b3b
commit 0a4df01354
9 changed files with 139 additions and 14 deletions

View File

@@ -11,6 +11,7 @@
<ResourceDictionary Source="Styles/HamburgerButtonStyle.xaml" /> <ResourceDictionary Source="Styles/HamburgerButtonStyle.xaml" />
<ResourceDictionary Source="Styles/ListViewLeftIndicatorStyle.xaml" /> <ResourceDictionary Source="Styles/ListViewLeftIndicatorStyle.xaml" />
<ResourceDictionary Source="Styles/NoBorderButtonStyle.xaml" /> <ResourceDictionary Source="Styles/NoBorderButtonStyle.xaml" />
<ResourceDictionary Source="Styles/BreadcrumbStyle.xaml" />
<ResourceDictionary Source="Styles/Styles.xaml" /> <ResourceDictionary Source="Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -0,0 +1,55 @@
using System.Collections.Generic;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using ModernKeePass.Interfaces;
// The Templated Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234235
namespace ModernKeePass.Controls
{
public class Breadcrumb : Control
{
public Breadcrumb()
{
DefaultStyleKey = typeof(Breadcrumb);
}
public string TargetPage
{
get { return (string)GetValue(TargetPageProperty); }
set { SetValue(TargetPageProperty, value); }
}
public static readonly DependencyProperty TargetPageProperty =
DependencyProperty.Register(
"TargetPage",
typeof(string),
typeof(Breadcrumb),
new PropertyMetadata(string.Empty, (o, args) => { }));
public Symbol SeparatorSymbol
{
get { return (Symbol)GetValue(SeparatorSymbolProperty); }
set { SetValue(SeparatorSymbolProperty, value); }
}
public static readonly DependencyProperty SeparatorSymbolProperty =
DependencyProperty.Register(
"SeparatorSymbol",
typeof(Symbol),
typeof(Breadcrumb),
new PropertyMetadata(Symbol.Forward, (o, args) => { }));
public IEnumerable<IPwEntity> PathItems
{
get { return (IEnumerable<IPwEntity>)GetValue(PathItemsProperty); }
set { SetValue(PathItemsProperty, value); }
}
public static readonly DependencyProperty PathItemsProperty =
DependencyProperty.Register(
"PathItems",
typeof(IEnumerable<>),
typeof(Breadcrumb),
new PropertyMetadata(null, (o, args) => { }));
}
}

View File

@@ -114,6 +114,7 @@
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\Breadcrumb.cs" />
<Compile Include="Exceptions\DatabaseOpenedException.cs" /> <Compile Include="Exceptions\DatabaseOpenedException.cs" />
<Compile Include="Interfaces\ILicenseService.cs" /> <Compile Include="Interfaces\ILicenseService.cs" />
<Compile Include="Interfaces\IProxyInvocationHandler.cs" /> <Compile Include="Interfaces\IProxyInvocationHandler.cs" />
@@ -247,6 +248,11 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="Styles\BreadcrumbStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
<Page Include="Styles\Colors.xaml"> <Page Include="Styles\Colors.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@@ -2,6 +2,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Windows.Storage; using Windows.Storage;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Microsoft.HockeyApp;
using ModernKeePass.Exceptions; using ModernKeePass.Exceptions;
using ModernKeePass.Interfaces; using ModernKeePass.Interfaces;
using ModernKeePass.ViewModels; using ModernKeePass.ViewModels;
@@ -146,6 +147,7 @@ namespace ModernKeePass.Services
} }
catch (InvalidCompositeKeyException ex) catch (InvalidCompositeKeyException ex)
{ {
HockeyClient.Current.TrackException(ex);
throw new ArgumentException(ex.Message, ex); throw new ArgumentException(ex.Message, ex);
} }
} }

View File

@@ -0,0 +1,58 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:ModernKeePass.Controls"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors">
<Style TargetType="controls:Breadcrumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Breadcrumb">
<ItemsControl ItemsSource="{TemplateBinding PathItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<DataTemplate x:Name="FirstItemTemplate">
<TextBlock>
<Hyperlink Foreground="{StaticResource MainColor}">
<Run Text="{Binding Name}" />
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click" >
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="{TemplateBinding TargetPage}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Hyperlink>
</TextBlock>
</DataTemplate>
<DataTemplate x:Name="OtherItemsTemplate">
<StackPanel Orientation="Horizontal">
<Viewbox MaxHeight="12" >
<SymbolIcon Symbol="{TemplateBinding SeparatorSymbol}" />
</Viewbox>
<TextBlock>
<Hyperlink Foreground="{StaticResource MainColor}">
<Run Text="{Binding Name}" />
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click" >
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="{TemplateBinding TargetPage}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</ItemsControl.Resources>
<ItemsControl.ItemTemplateSelector>
<templateSelectors:FirstItemDataTemplateSelector FirstItem="{StaticResource FirstItemTemplate}" OtherItem="{StaticResource OtherItemsTemplate}"/>
</ItemsControl.ItemTemplateSelector>
</ItemsControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -143,6 +143,7 @@ namespace ModernKeePass.ViewModels
} }
} }
[Obsolete]
public string Path public string Path
{ {
get get

View File

@@ -93,22 +93,23 @@ namespace ModernKeePass.ViewModels
set { SetProperty(ref _isMenuClosed, value); } set { SetProperty(ref _isMenuClosed, value); }
} }
public ObservableCollection<GroupVm> BreadCrumb public Stack<GroupVm> BreadCrumb
{ {
get get
{ {
var groups = new ObservableCollection<GroupVm>(); var groups = new Stack<GroupVm>();
var group = this; var group = this;
while (group.ParentGroup != null) while (group.ParentGroup != null)
{ {
group = group.ParentGroup; group = group.ParentGroup;
groups.Insert(0, group); groups.Push(group);
} }
return groups; return groups;
} }
} }
[Obsolete]
public string Path public string Path
{ {
get get

View File

@@ -9,6 +9,7 @@
xmlns:core="using:Microsoft.Xaml.Interactions.Core" xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:actions="using:ModernKeePass.Actions" xmlns:actions="using:ModernKeePass.Actions"
xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors" xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors"
xmlns:controls="using:ModernKeePass.Controls"
x:Name="PageRoot" x:Name="PageRoot"
x:Class="ModernKeePass.Views.GroupDetailPage" x:Class="ModernKeePass.Views.GroupDetailPage"
mc:Ignorable="d" mc:Ignorable="d"
@@ -95,7 +96,10 @@
Source="{Binding Entries}" /> Source="{Binding Entries}" />
<CollectionViewSource <CollectionViewSource
x:Name="EntriesZoomedOutViewSource" x:Name="EntriesZoomedOutViewSource"
Source="{Binding EntriesZoomedOut}" IsSourceGrouped="True"/> Source="{Binding EntriesZoomedOut}" IsSourceGrouped="True" />
<CollectionViewSource
x:Name="BreadCrumbViewSource"
Source="{Binding BreadCrumb}" />
</Grid.Resources> </Grid.Resources>
<Grid.Background> <Grid.Background>
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/> <StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
@@ -210,6 +214,7 @@
<!-- Horizontal scrolling grid --> <!-- Horizontal scrolling grid -->
<GridView <GridView
x:Name="GridView" x:Name="GridView"
ItemsSource="{Binding Source={StaticResource EntriesViewSource}}"
AutomationProperties.AutomationId="ItemGridView" AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Entries" AutomationProperties.Name="Entries"
TabIndex="1" TabIndex="1"
@@ -275,12 +280,6 @@
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</GridView.ItemTemplate> </GridView.ItemTemplate>
<GridView.ItemsSource>
<Binding Source="{StaticResource EntriesViewSource}"/>
</GridView.ItemsSource>
<GridView.DataContext>
<viewModels:EntryVm/>
</GridView.DataContext>
</GridView> </GridView>
</SemanticZoom.ZoomedInView> </SemanticZoom.ZoomedInView>
<SemanticZoom.ZoomedOutView> <SemanticZoom.ZoomedOutView>
@@ -347,7 +346,8 @@
</core:DataTriggerBehavior> </core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>
</TextBox> </TextBox>
<TextBlock FontSize="12" Text="{Binding Path}" /> <!--<TextBlock FontSize="12" Text="{Binding Path}" />-->
<controls:Breadcrumb PathItems="{Binding Source={StaticResource BreadCrumbViewSource}}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
</StackPanel> </StackPanel>
<Button Grid.Column="2" x:Name="SearchButton" Style="{StaticResource NoBorderButtonStyle}" Height="50"> <Button Grid.Column="2" x:Name="SearchButton" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Find" /> <SymbolIcon Symbol="Find" />

View File

@@ -24,7 +24,8 @@
<Run x:Uid="AboutHomepage" /> <Run x:Uid="AboutHomepage" />
<Hyperlink NavigateUri="https://github.com/wismna/ModernKeePass" Foreground="{StaticResource MainColor}"> <Hyperlink NavigateUri="https://github.com/wismna/ModernKeePass" Foreground="{StaticResource MainColor}">
<Run Text="https://github.com/wismna/ModernKeePass"/> <Run Text="https://github.com/wismna/ModernKeePass"/>
</Hyperlink></TextBlock> </Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="10,0,0,0"> <TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="10,0,0,0">
<Run x:Uid="AboutCreditsLabel" /> <Run x:Uid="AboutCreditsLabel" />
</TextBlock> </TextBlock>