WIP Breadcrumb

Breadcrumb is now a working User Control (removal of the Templated Control)
AssemblyInfo updated
Some code cleanup
This commit is contained in:
BONNEVILLE Geoffroy
2018-06-13 18:58:28 +02:00
parent 0a4df01354
commit cc65c56042
13 changed files with 96 additions and 160 deletions

View File

@@ -11,7 +11,6 @@
<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

@@ -1,55 +0,0 @@
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

@@ -10,7 +10,6 @@ namespace ModernKeePass.Interfaces
Symbol IconSymbol { get; } Symbol IconSymbol { get; }
string Id { get; } string Id { get; }
string Name { get; set; } string Name { get; set; }
string Path { get; }
bool IsEditMode { get; } bool IsEditMode { get; }
bool IsRecycleOnDelete { get; } bool IsRecycleOnDelete { get; }

View File

@@ -114,7 +114,6 @@
<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" />
@@ -166,6 +165,9 @@
</Compile> </Compile>
<Compile Include="TemplateSelectors\FirstItemDataTemplateSelector.cs" /> <Compile Include="TemplateSelectors\FirstItemDataTemplateSelector.cs" />
<Compile Include="Controls\ListViewWithDisable.cs" /> <Compile Include="Controls\ListViewWithDisable.cs" />
<Compile Include="Views\UserControls\BreadCrumbUserControl.xaml.cs">
<DependentUpon>BreadCrumbUserControl.xaml</DependentUpon>
</Compile>
<Compile Include="Views\UserControls\CompositeKeyUserControl.xaml.cs"> <Compile Include="Views\UserControls\CompositeKeyUserControl.xaml.cs">
<DependentUpon>CompositeKeyUserControl.xaml</DependentUpon> <DependentUpon>CompositeKeyUserControl.xaml</DependentUpon>
</Compile> </Compile>
@@ -248,11 +250,6 @@
<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>
@@ -262,6 +259,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\UserControls\BreadCrumbUserControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\UserControls\CompositeKeyUserControl.xaml"> <Page Include="Views\UserControls\CompositeKeyUserControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -10,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("wismna")] [assembly: AssemblyCompany("wismna")]
[assembly: AssemblyProduct("ModernKeePass")] [assembly: AssemblyProduct("ModernKeePass")]
[assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@@ -24,6 +23,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.13.0.0")] [assembly: AssemblyVersion("1.14.0.0")]
[assembly: AssemblyFileVersion("1.13.0.0")] [assembly: AssemblyFileVersion("1.14.0.0")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View File

@@ -1,58 +0,0 @@
<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

@@ -11,7 +11,7 @@ namespace ModernKeePass.TemplateSelectors
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{ {
var itemsControl = ItemsControl.ItemsControlFromItemContainer(container); var itemsControl = ItemsControl.ItemsControlFromItemContainer(container);
var returnTemplate = itemsControl.IndexFromContainer(container) == 0 ? FirstItem : OtherItem; var returnTemplate = itemsControl?.IndexFromContainer(container) == 0 ? FirstItem : OtherItem;
return returnTemplate; return returnTemplate;
} }
} }

View File

@@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Text;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using ModernKeePass.Interfaces; using ModernKeePass.Interfaces;
using ModernKeePass.Mappings; using ModernKeePass.Mappings;
@@ -143,16 +143,7 @@ namespace ModernKeePass.ViewModels
} }
} }
[Obsolete] public IEnumerable<IPwEntity> BreadCrumb => new List<IPwEntity>(ParentGroup.BreadCrumb) {ParentGroup};
public string Path
{
get
{
var path = new StringBuilder(ParentGroup.Path);
path.Append($" > {ParentGroup.Name}");
return path.ToString();
}
}
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
@@ -168,7 +159,7 @@ namespace ModernKeePass.ViewModels
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
public EntryVm() { } public EntryVm(): this(null, null) { }
internal EntryVm(PwEntry entry, GroupVm parent) : this(entry, parent, DatabaseService.Instance) { } internal EntryVm(PwEntry entry, GroupVm parent) : this(entry, parent, DatabaseService.Instance) { }

View File

@@ -93,7 +93,7 @@ namespace ModernKeePass.ViewModels
set { SetProperty(ref _isMenuClosed, value); } set { SetProperty(ref _isMenuClosed, value); }
} }
public Stack<GroupVm> BreadCrumb public IEnumerable<IPwEntity> BreadCrumb
{ {
get get
{ {
@@ -109,18 +109,6 @@ namespace ModernKeePass.ViewModels
} }
} }
[Obsolete]
public string Path
{
get
{
if (ParentGroup == null) return string.Empty;
var path = new StringBuilder(ParentGroup.Path);
path.Append($" > {ParentGroup.Name}");
return path.ToString();
}
}
private readonly PwGroup _pwGroup; private readonly PwGroup _pwGroup;
private readonly IDatabaseService _database; private readonly IDatabaseService _database;
private bool _isEditMode; private bool _isEditMode;

View File

@@ -9,6 +9,7 @@
xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
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:userControls="using:ModernKeePass.Views.UserControls"
x:Name="PageRoot" x:Name="PageRoot"
x:Class="ModernKeePass.Views.EntryDetailPage" x:Class="ModernKeePass.Views.EntryDetailPage"
mc:Ignorable="d" mc:Ignorable="d"
@@ -458,7 +459,7 @@
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="350" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" /> <ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="350" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" />
<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:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="&#xE111;" ButtonTooltip="Navigate to URL"> <local:TextBoxWithButton HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="&#xE111;" ButtonTooltip="Navigate to URL">
<interactivity:Interaction.Behaviors> <interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ButtonClick"> <core:EventTriggerBehavior EventName="ButtonClick">
<actions:NavigateToUrlAction Url="{Binding Url}" /> <actions:NavigateToUrlAction Url="{Binding Url}" />
@@ -520,7 +521,7 @@
</core:DataTriggerBehavior> </core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>
</TextBox> </TextBox>
<TextBlock FontSize="12" Text="{Binding Path}" /> <userControls:BreadCrumbUserControl ItemsSource="{Binding BreadCrumb}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>

View File

@@ -9,7 +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" xmlns:userControls="using:ModernKeePass.Views.UserControls"
x:Name="PageRoot" x:Name="PageRoot"
x:Class="ModernKeePass.Views.GroupDetailPage" x:Class="ModernKeePass.Views.GroupDetailPage"
mc:Ignorable="d" mc:Ignorable="d"
@@ -97,9 +97,6 @@
<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"/>
@@ -180,7 +177,7 @@
</core:EventTriggerBehavior> </core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>
</ToggleButton> </ToggleButton>
<TextBlock x:Uid="GroupsHeaderTextBlock" FontWeight="Bold" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" /> <TextBlock x:Uid="GroupsHeaderTextBlock" FontWeight="Bold" FontSize="18" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="30,0,20,0" HorizontalAlignment="Center" />
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ListView.HeaderTemplate> </ListView.HeaderTemplate>
@@ -346,8 +343,7 @@
</core:DataTriggerBehavior> </core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>
</TextBox> </TextBox>
<!--<TextBlock FontSize="12" Text="{Binding Path}" />--> <userControls:BreadCrumbUserControl ItemsSource="{Binding BreadCrumb}" />
<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

@@ -0,0 +1,46 @@
<UserControl x:Name="UserControl"
x:Class="ModernKeePass.Views.UserControls.BreadCrumbUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors"
mc:Ignorable="d">
<ItemsControl ItemsSource="{Binding ItemsSource, ElementName=UserControl}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<DataTemplate x:Name="FirstItemTemplate">
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Name}" Style="{StaticResource MainColorHyperlinkButton}" FontSize="12" Padding="0">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</HyperlinkButton>
</DataTemplate>
<DataTemplate x:Name="OtherItemsTemplate">
<StackPanel Orientation="Horizontal">
<Viewbox MaxHeight="12">
<SymbolIcon Symbol="Forward" />
</Viewbox>
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Name}" Style="{StaticResource MainColorHyperlinkButton}" FontSize="12" Padding="0">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</ItemsControl.Resources>
<ItemsControl.ItemTemplateSelector>
<templateSelectors:FirstItemDataTemplateSelector FirstItem="{StaticResource FirstItemTemplate}" OtherItem="{StaticResource OtherItemsTemplate}"/>
</ItemsControl.ItemTemplateSelector>
</ItemsControl>
</UserControl>

View File

@@ -0,0 +1,29 @@
using System.Collections.Generic;
using Windows.UI.Xaml;
using ModernKeePass.Interfaces;
// 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 BreadCrumbUserControl()
{
InitializeComponent();
}
public IEnumerable<IPwEntity> ItemsSource
{
get { return (IEnumerable<IPwEntity>)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource",
typeof(IEnumerable<IPwEntity>),
typeof(BreadCrumbUserControl),
new PropertyMetadata(new Stack<IPwEntity>(), (o, args) => { }));
}
}