From 2ab84ef4aff4e29c5a0c8ce86370203d9e7c4cbd Mon Sep 17 00:00:00 2001 From: BONNEVILLE Geoffroy Date: Thu, 5 Jul 2018 18:32:42 +0200 Subject: [PATCH] WIP Top Menu - Overflow mechanism works, commands implemented --- ModernKeePass/App.xaml | 1 + ModernKeePass/ModernKeePass.App.csproj | 5 + .../NoBorderButtonStyle.xaml | 3 +- .../NoBorderToggleButtonStyle.xaml | 204 ++++++++++++++++++ ModernKeePass/Views/GroupDetailPage.xaml | 29 ++- .../UserControls/TopMenuUserControl.xaml | 108 +++------- .../UserControls/TopMenuUserControl.xaml.cs | 80 +++++-- 7 files changed, 331 insertions(+), 99 deletions(-) create mode 100644 ModernKeePass/ResourceDictionaries/NoBorderToggleButtonStyle.xaml diff --git a/ModernKeePass/App.xaml b/ModernKeePass/App.xaml index a34dd27..629aaa4 100644 --- a/ModernKeePass/App.xaml +++ b/ModernKeePass/App.xaml @@ -11,6 +11,7 @@ + diff --git a/ModernKeePass/ModernKeePass.App.csproj b/ModernKeePass/ModernKeePass.App.csproj index 5749688..f5126f5 100644 --- a/ModernKeePass/ModernKeePass.App.csproj +++ b/ModernKeePass/ModernKeePass.App.csproj @@ -268,6 +268,11 @@ MSBuild:Compile PreserveNewest + + Designer + MSBuild:Compile + PreserveNewest + Designer MSBuild:Compile diff --git a/ModernKeePass/ResourceDictionaries/NoBorderButtonStyle.xaml b/ModernKeePass/ResourceDictionaries/NoBorderButtonStyle.xaml index dc2a3d5..1e9d898 100644 --- a/ModernKeePass/ResourceDictionaries/NoBorderButtonStyle.xaml +++ b/ModernKeePass/ResourceDictionaries/NoBorderButtonStyle.xaml @@ -1,7 +1,6 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + diff --git a/ModernKeePass/Views/GroupDetailPage.xaml b/ModernKeePass/Views/GroupDetailPage.xaml index ad1294d..82af727 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml +++ b/ModernKeePass/Views/GroupDetailPage.xaml @@ -280,8 +280,19 @@ + IsEditButtonChecked="{Binding IsEditMode, Mode=TwoWay}" + IsDeleteButtonEnabled="{Binding IsNotRoot}" + SaveCommand="{Binding SaveCommand}" + RestoreCommand="{Binding UndoDeleteCommand}"> + + + + + + + + + - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml.cs b/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml.cs index 2332623..744a02d 100644 --- a/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml.cs +++ b/ModernKeePass/Views/UserControls/TopMenuUserControl.xaml.cs @@ -7,18 +7,6 @@ namespace ModernKeePass.Views.UserControls { public sealed partial class TopMenuUserControl { - public string VisualState - { - get { return (string)GetValue(VisualStateProperty); } - set { SetValue(VisualStateProperty, value); } - } - public static readonly DependencyProperty VisualStateProperty = - DependencyProperty.Register( - "VisualState", - typeof(string), - typeof(TopMenuUserControl), - new PropertyMetadata("None", (o, args) => { })); - public ICommand SaveCommand { get { return (ICommand)GetValue(SaveCommandProperty); } @@ -91,21 +79,79 @@ namespace ModernKeePass.Views.UserControls typeof(TopMenuUserControl), new PropertyMetadata(false, (o, args) => { })); - public bool EnableDeleteButton + public Visibility MoreButtonVisibility { - get { return (bool)GetValue(EnableDeleteButtonProperty); } - set { SetValue(EnableDeleteButtonProperty, value); } + get { return (Visibility)GetValue(MoreButtonVisibilityProperty); } + set { SetValue(MoreButtonVisibilityProperty, value); } } - public static readonly DependencyProperty EnableDeleteButtonProperty = + public static readonly DependencyProperty MoreButtonVisibilityProperty = DependencyProperty.Register( - "EnableDeleteButton", + "MoreButtonVisibility", + typeof(Visibility), + typeof(TopMenuUserControl), + new PropertyMetadata(false, (o, args) => { })); + + public Visibility OverflowButtonsVisibility + { + get { return (Visibility)GetValue(OverflowButtonsVisibilityProperty); } + set { SetValue(OverflowButtonsVisibilityProperty, value); } + } + public static readonly DependencyProperty OverflowButtonsVisibilityProperty = + DependencyProperty.Register( + "OverflowButtonsVisibility", + typeof(Visibility), + typeof(TopMenuUserControl), + new PropertyMetadata(false, (o, args) => { })); + + public bool IsDeleteButtonEnabled + { + get { return (bool)GetValue(IsDeleteButtonEnabledProperty); } + set { SetValue(IsDeleteButtonEnabledProperty, value); } + } + public static readonly DependencyProperty IsDeleteButtonEnabledProperty = + DependencyProperty.Register( + "IsDeleteButtonEnabled", typeof(bool), typeof(TopMenuUserControl), new PropertyMetadata(true, (o, args) => { })); + public bool IsEditButtonChecked + { + get { return (bool)GetValue(IsEditButtonCheckedProperty); } + set { SetValue(IsEditButtonCheckedProperty, value); } + } + public static readonly DependencyProperty IsEditButtonCheckedProperty = + DependencyProperty.Register( + "IsEditButtonChecked", + typeof(bool), + typeof(TopMenuUserControl), + new PropertyMetadata(false, (o, args) => { })); + + public event EditButtonClickEventHandler EditButtonClick; + public delegate void EditButtonClickEventHandler(object sender, RoutedEventArgs e); + public event DeleteButtonClickEventHandler DeleteButtonClick; + public delegate void DeleteButtonClickEventHandler(object sender, RoutedEventArgs e); + public event RestoreButtonClickEventHandler RestoreButtonClick; + public delegate void RestoreButtonClickEventHandler(object sender, RoutedEventArgs e); + public TopMenuUserControl() { InitializeComponent(); } + + private void EditButton_Click(object sender, RoutedEventArgs e) + { + EditButtonClick?.Invoke(sender, e); + } + + private void DeleteButton_Click(object sender, RoutedEventArgs e) + { + DeleteButtonClick?.Invoke(sender, e); + } + + private void RestoreButton_Click(object sender, RoutedEventArgs e) + { + RestoreButtonClick?.Invoke(sender, e); + } } }