2018-07-25 18:39:03 +02:00
|
|
|
|
using System;
|
2018-08-03 17:41:52 +02:00
|
|
|
|
using System.Windows.Input;
|
2018-07-02 18:23:43 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
|
|
|
|
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Views.UserControls
|
|
|
|
|
{
|
|
|
|
|
public sealed partial class TopMenuUserControl
|
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
public ICommand SaveCommand
|
2018-07-02 18:23:43 +02:00
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
get { return (ICommand)GetValue(SaveCommandProperty); }
|
2018-07-02 18:23:43 +02:00
|
|
|
|
set { SetValue(SaveCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SaveCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"SaveCommand",
|
2018-08-03 17:41:52 +02:00
|
|
|
|
typeof(ICommand),
|
2018-07-02 18:23:43 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2018-08-03 17:41:52 +02:00
|
|
|
|
public ICommand EditCommand
|
2018-07-02 18:23:43 +02:00
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
get { return (ICommand)GetValue(EditCommandProperty); }
|
2018-07-02 18:23:43 +02:00
|
|
|
|
set { SetValue(EditCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty EditCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"EditCommand",
|
2018-08-03 17:41:52 +02:00
|
|
|
|
typeof(ICommand),
|
2018-07-02 18:23:43 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2018-08-03 17:41:52 +02:00
|
|
|
|
public ICommand DeleteCommand
|
2018-07-02 18:23:43 +02:00
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
get { return (ICommand)GetValue(DeleteCommandProperty); }
|
2018-07-02 18:23:43 +02:00
|
|
|
|
set { SetValue(DeleteCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty DeleteCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"DeleteCommand",
|
2018-08-03 17:41:52 +02:00
|
|
|
|
typeof(ICommand),
|
2018-07-02 18:23:43 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2018-08-03 17:41:52 +02:00
|
|
|
|
public ICommand RestoreCommand
|
2018-07-02 18:23:43 +02:00
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
get { return (ICommand)GetValue(RestoreCommandProperty); }
|
2018-07-02 18:23:43 +02:00
|
|
|
|
set { SetValue(RestoreCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty RestoreCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"RestoreCommand",
|
2018-08-03 17:41:52 +02:00
|
|
|
|
typeof(ICommand),
|
2018-07-02 18:23:43 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
2018-07-11 12:15:56 +02:00
|
|
|
|
|
2018-08-03 17:41:52 +02:00
|
|
|
|
public ICommand SortEntriesCommand
|
2018-07-11 12:15:56 +02:00
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
get { return (ICommand)GetValue(SortEntriesCommandProperty); }
|
2018-07-11 12:15:56 +02:00
|
|
|
|
set { SetValue(SortEntriesCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SortEntriesCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"SortEntriesCommand",
|
2018-08-03 17:41:52 +02:00
|
|
|
|
typeof(ICommand),
|
2018-07-11 12:15:56 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
2018-07-02 18:23:43 +02:00
|
|
|
|
|
2018-08-03 17:41:52 +02:00
|
|
|
|
public ICommand SortGroupsCommand
|
2018-07-11 12:15:56 +02:00
|
|
|
|
{
|
2018-08-03 17:41:52 +02:00
|
|
|
|
get { return (ICommand)GetValue(SortGroupsCommandProperty); }
|
2018-07-11 12:15:56 +02:00
|
|
|
|
set { SetValue(SortGroupsCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SortGroupsCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"SortGroupsCommand",
|
2018-08-03 17:41:52 +02:00
|
|
|
|
typeof(ICommand),
|
2018-07-11 12:15:56 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2018-07-04 18:26:16 +02:00
|
|
|
|
public Visibility RestoreButtonVisibility
|
2018-07-02 18:23:43 +02:00
|
|
|
|
{
|
2018-07-04 18:26:16 +02:00
|
|
|
|
get { return (Visibility)GetValue(RestoreButtonVisibilityProperty); }
|
|
|
|
|
set { SetValue(RestoreButtonVisibilityProperty, value); }
|
2018-07-02 18:23:43 +02:00
|
|
|
|
}
|
2018-07-04 18:26:16 +02:00
|
|
|
|
public static readonly DependencyProperty RestoreButtonVisibilityProperty =
|
2018-07-02 18:23:43 +02:00
|
|
|
|
DependencyProperty.Register(
|
2018-07-04 18:26:16 +02:00
|
|
|
|
"RestoreButtonVisibility",
|
|
|
|
|
typeof(Visibility),
|
|
|
|
|
typeof(TopMenuUserControl),
|
2018-07-11 12:15:56 +02:00
|
|
|
|
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
2018-07-04 18:26:16 +02:00
|
|
|
|
|
|
|
|
|
public Visibility DeleteButtonVisibility
|
|
|
|
|
{
|
|
|
|
|
get { return (Visibility)GetValue(DeleteButtonVisibilityProperty); }
|
|
|
|
|
set { SetValue(DeleteButtonVisibilityProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty DeleteButtonVisibilityProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"DeleteButtonVisibility",
|
|
|
|
|
typeof(Visibility),
|
2018-07-02 18:23:43 +02:00
|
|
|
|
typeof(TopMenuUserControl),
|
2018-07-11 12:15:56 +02:00
|
|
|
|
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
2018-07-02 18:23:43 +02:00
|
|
|
|
|
2018-07-05 18:32:42 +02:00
|
|
|
|
public Visibility MoreButtonVisibility
|
|
|
|
|
{
|
|
|
|
|
get { return (Visibility)GetValue(MoreButtonVisibilityProperty); }
|
|
|
|
|
set { SetValue(MoreButtonVisibilityProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty MoreButtonVisibilityProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"MoreButtonVisibility",
|
|
|
|
|
typeof(Visibility),
|
|
|
|
|
typeof(TopMenuUserControl),
|
2018-07-11 12:15:56 +02:00
|
|
|
|
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
2018-07-05 18:32:42 +02:00
|
|
|
|
|
|
|
|
|
public Visibility OverflowButtonsVisibility
|
|
|
|
|
{
|
|
|
|
|
get { return (Visibility)GetValue(OverflowButtonsVisibilityProperty); }
|
|
|
|
|
set { SetValue(OverflowButtonsVisibilityProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty OverflowButtonsVisibilityProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"OverflowButtonsVisibility",
|
|
|
|
|
typeof(Visibility),
|
|
|
|
|
typeof(TopMenuUserControl),
|
2018-07-11 12:15:56 +02:00
|
|
|
|
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
|
|
|
|
|
|
|
|
|
public Visibility SortButtonVisibility
|
|
|
|
|
{
|
|
|
|
|
get { return (Visibility)GetValue(SortButtonVisibilityProperty); }
|
|
|
|
|
set { SetValue(SortButtonVisibilityProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SortButtonVisibilityProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"SortButtonVisibility",
|
|
|
|
|
typeof(Visibility),
|
|
|
|
|
typeof(TopMenuUserControl),
|
2018-08-02 17:40:30 +02:00
|
|
|
|
new PropertyMetadata(Visibility.Visible, (o, args) => { }));
|
2018-07-05 18:32:42 +02:00
|
|
|
|
|
|
|
|
|
public bool IsDeleteButtonEnabled
|
2018-07-04 18:26:16 +02:00
|
|
|
|
{
|
2018-07-05 18:32:42 +02:00
|
|
|
|
get { return (bool)GetValue(IsDeleteButtonEnabledProperty); }
|
|
|
|
|
set { SetValue(IsDeleteButtonEnabledProperty, value); }
|
2018-07-04 18:26:16 +02:00
|
|
|
|
}
|
2018-07-05 18:32:42 +02:00
|
|
|
|
public static readonly DependencyProperty IsDeleteButtonEnabledProperty =
|
2018-07-04 18:26:16 +02:00
|
|
|
|
DependencyProperty.Register(
|
2018-07-05 18:32:42 +02:00
|
|
|
|
"IsDeleteButtonEnabled",
|
2018-07-04 18:26:16 +02:00
|
|
|
|
typeof(bool),
|
|
|
|
|
typeof(TopMenuUserControl),
|
|
|
|
|
new PropertyMetadata(true, (o, args) => { }));
|
2018-07-02 18:23:43 +02:00
|
|
|
|
|
2018-07-05 18:32:42 +02:00
|
|
|
|
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) => { }));
|
|
|
|
|
|
2018-07-25 18:39:03 +02:00
|
|
|
|
public event EventHandler<RoutedEventArgs> EditButtonClick;
|
|
|
|
|
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
|
|
|
|
|
public event EventHandler<RoutedEventArgs> RestoreButtonClick;
|
2018-07-05 18:32:42 +02:00
|
|
|
|
|
2018-07-02 18:23:43 +02:00
|
|
|
|
public TopMenuUserControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2018-07-11 12:15:56 +02:00
|
|
|
|
EditFlyout.Click += EditFlyout_Click;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EditFlyout_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IsEditButtonChecked = EditFlyout.IsChecked;
|
|
|
|
|
EditButton_Click(sender, e);
|
2018-07-02 18:23:43 +02:00
|
|
|
|
}
|
2018-07-05 18:32:42 +02:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2018-07-10 18:26:27 +02:00
|
|
|
|
|
2018-07-11 13:48:15 +02:00
|
|
|
|
private void OverflowFlyout_OnOpening(object sender, object e)
|
2018-07-10 18:26:27 +02:00
|
|
|
|
{
|
|
|
|
|
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
|
|
|
|
|
DeleteFlyout.Visibility = DeleteButtonVisibility;
|
|
|
|
|
|
|
|
|
|
EditFlyout.IsChecked = IsEditButtonChecked;
|
2018-08-02 17:40:30 +02:00
|
|
|
|
|
2018-07-10 18:26:27 +02:00
|
|
|
|
RestoreFlyout.Visibility = RestoreButtonVisibility;
|
2018-07-11 12:15:56 +02:00
|
|
|
|
|
|
|
|
|
SortEntriesFlyout.Visibility = SortButtonVisibility;
|
|
|
|
|
SortGroupsFlyout.Visibility = SortButtonVisibility;
|
2018-07-11 13:48:15 +02:00
|
|
|
|
SortEntriesFlyout.Command = SortEntriesCommand;
|
|
|
|
|
SortGroupsFlyout.Command = SortGroupsCommand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SortFlyout_OnOpening(object sender, object e)
|
|
|
|
|
{
|
|
|
|
|
SortEntriesButtonFlyout.Command = SortEntriesCommand;
|
|
|
|
|
SortGroupsButtonFlyout.Command = SortGroupsCommand;
|
2018-07-10 18:26:27 +02:00
|
|
|
|
}
|
2018-07-02 18:23:43 +02:00
|
|
|
|
}
|
|
|
|
|
}
|