WIP Top Menu - Button visibility ok when not in menu

This commit is contained in:
BONNEVILLE Geoffroy
2018-07-04 18:26:16 +02:00
parent 34f5f2f6c8
commit 056d1af9d0
5 changed files with 119 additions and 30 deletions

View File

@@ -420,4 +420,31 @@
<data name="HamburgerMenuSettingsTooltip.Content" xml:space="preserve">
<value>Settings</value>
</data>
<data name="TopMenuDeleteButton.Content" xml:space="preserve">
<value>Delete</value>
</data>
<data name="TopMenuDeleteFlyout.Text" xml:space="preserve">
<value>Delete</value>
</data>
<data name="TopMenuEditButton.Content" xml:space="preserve">
<value>Edit</value>
</data>
<data name="TopMenuEditFlyout.Text" xml:space="preserve">
<value>Edit</value>
</data>
<data name="TopMenuMoreButton.Content" xml:space="preserve">
<value>More</value>
</data>
<data name="TopMenuRestoreButton.Content" xml:space="preserve">
<value>Restore</value>
</data>
<data name="TopMenuRestoreFlyout.Text" xml:space="preserve">
<value>Restore</value>
</data>
<data name="TopMenuSaveButton.Content" xml:space="preserve">
<value>Save</value>
</data>
<data name="TopMenuSaveFlyout.Text" xml:space="preserve">
<value>Save</value>
</data>
</root>

View File

@@ -420,4 +420,31 @@
<data name="HamburgerMenuSettingsTooltip.Content" xml:space="preserve">
<value>Paramètres</value>
</data>
<data name="TopMenuDeleteButton.Content" xml:space="preserve">
<value>Supprimer</value>
</data>
<data name="TopMenuDeleteFlyout.Text" xml:space="preserve">
<value>Supprimer</value>
</data>
<data name="TopMenuEditButton.Content" xml:space="preserve">
<value>Editer</value>
</data>
<data name="TopMenuEditFlyout.Text" xml:space="preserve">
<value>Editer</value>
</data>
<data name="TopMenuMoreButton.Content" xml:space="preserve">
<value>Plus</value>
</data>
<data name="TopMenuRestoreButton.Content" xml:space="preserve">
<value>Restaurer</value>
</data>
<data name="TopMenuRestoreFlyout.Text" xml:space="preserve">
<value>Restaurer</value>
</data>
<data name="TopMenuSaveButton.Content" xml:space="preserve">
<value>Sauvegarder</value>
</data>
<data name="TopMenuSaveFlyout.Text" xml:space="preserve">
<value>Sauvegarder</value>
</data>
</root>

View File

@@ -277,7 +277,11 @@
</TextBox>
<userControls:BreadCrumbUserControl ItemsSource="{Binding BreadCrumb}" Margin="5,-5,0,0" />
</StackPanel>
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="2" ShowRestoreButton="{Binding ShowRestore}" />
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="2"
RestoreButtonVisibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}"
DeleteButtonVisibility="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}"
VisualState="Large"
EnableDeleteButton="{Binding IsNotRoot}" />
<Button Grid.Column="3" x:Name="SearchButton" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Find" />
<Button.Flyout>

View File

@@ -4,32 +4,44 @@
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:converters="using:ModernKeePass.Converters"
mc:Ignorable="d">
<UserControl.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>
<StackPanel Orientation="Horizontal">
<Button x:Name="RestoreButton" x:Uid="TopMenuRestoreButton" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding ShowRestoreButton, ElementName=UserControl, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Undo" />
<Button x:Name="RestoreButton" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Undo">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuRestoreButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</Button>
<Button x:Name="SaveButton" x:Uid="TopMenuSaveButton" Command="{Binding SaveCommand, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Save" />
<Button x:Name="SaveButton" Command="{Binding SaveCommand, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Save">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuSaveButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</Button>
<Button x:Name="EditButton" x:Uid="TopMenuEditButton" Command="{Binding EditCommand, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Edit" />
<Button x:Name="EditButton" Command="{Binding EditCommand, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Edit">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuEditButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</Button>
<Button x:Name="DeleteButton" x:Uid="TopMenuDeleteButton" Command="{Binding DeleteCommand, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Delete" />
<Button x:Name="DeleteButton" Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding EnableDeleteButton, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Delete">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuDeleteButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</Button>
<Button x:Name="MoreButton" x:Uid="TopMenuMoreButton" Command="{Binding SaveCommand, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<Button x:Name="MoreButton" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="More" />
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="TopMenuRestoreButton" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding ShowRestoreButton, ElementName=UserControl, Converter={StaticResource BooleanToVisibilityConverter}}" />
<MenuFlyoutItem x:Uid="TopMenuSaveButton" Command="{Binding SaveCommand, ElementName=UserControl}"/>
<MenuFlyoutItem x:Uid="TopMenuEditButton" Command="{Binding EditCommand, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuDeleteButton" Command="{Binding DeleteCommand, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuEditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" IsEnabled="{Binding EnableDeleteButton, ElementName=UserControl}" />
</MenuFlyout>
</Button.Flyout>
</Button>

View File

@@ -10,18 +10,14 @@ namespace ModernKeePass.Views.UserControls
public string VisualState
{
get { return (string)GetValue(VisualStateProperty); }
set
{
SetValue(VisualStateProperty, value);
VisualStateManager.GoToState(this, value, true);
}
set { SetValue(VisualStateProperty, value); }
}
public static readonly DependencyProperty VisualStateProperty =
DependencyProperty.Register(
"VisualState",
typeof(string),
typeof(TopMenuUserControl),
new PropertyMetadata("Large", (o, args) => { }));
new PropertyMetadata("None", (o, args) => { }));
public ICommand SaveCommand
{
@@ -71,18 +67,41 @@ namespace ModernKeePass.Views.UserControls
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
public bool ShowRestoreButton
public Visibility RestoreButtonVisibility
{
get { return (bool)GetValue(ShowRestoreButtonProperty); }
set { SetValue(ShowRestoreButtonProperty, value); }
get { return (Visibility)GetValue(RestoreButtonVisibilityProperty); }
set { SetValue(RestoreButtonVisibilityProperty, value); }
}
public static readonly DependencyProperty ShowRestoreButtonProperty =
public static readonly DependencyProperty RestoreButtonVisibilityProperty =
DependencyProperty.Register(
"ShowRestoreButton",
typeof(bool),
"RestoreButtonVisibility",
typeof(Visibility),
typeof(TopMenuUserControl),
new PropertyMetadata(false, (o, args) => { }));
public Visibility DeleteButtonVisibility
{
get { return (Visibility)GetValue(DeleteButtonVisibilityProperty); }
set { SetValue(DeleteButtonVisibilityProperty, value); }
}
public static readonly DependencyProperty DeleteButtonVisibilityProperty =
DependencyProperty.Register(
"DeleteButtonVisibility",
typeof(Visibility),
typeof(TopMenuUserControl),
new PropertyMetadata(false, (o, args) => { }));
public bool EnableDeleteButton
{
get { return (bool)GetValue(EnableDeleteButtonProperty); }
set { SetValue(EnableDeleteButtonProperty, value); }
}
public static readonly DependencyProperty EnableDeleteButtonProperty =
DependencyProperty.Register(
"EnableDeleteButton",
typeof(bool),
typeof(TopMenuUserControl),
new PropertyMetadata(true, (o, args) => { }));
public TopMenuUserControl()
{