2018-07-26 12:01:49 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-04-28 15:20:47 +02:00
|
|
|
|
using System.Windows.Input;
|
2018-06-14 18:38:05 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
2020-03-30 19:43:04 +02:00
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
2018-06-14 18:38:05 +02:00
|
|
|
|
|
|
|
|
|
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Views.UserControls
|
|
|
|
|
{
|
|
|
|
|
public sealed partial class HamburgerMenuUserControl
|
|
|
|
|
{
|
|
|
|
|
public HamburgerMenuUserControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string HeaderLabel
|
|
|
|
|
{
|
|
|
|
|
get { return (string)GetValue(HeaderLabelProperty); }
|
|
|
|
|
set { SetValue(HeaderLabelProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty HeaderLabelProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(HeaderLabel),
|
2018-06-14 18:38:05 +02:00
|
|
|
|
typeof(string),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
|
|
|
|
new PropertyMetadata("Header", (o, args) => { }));
|
|
|
|
|
|
|
|
|
|
public string ButtonLabel
|
|
|
|
|
{
|
|
|
|
|
get { return (string)GetValue(ButtonLabelProperty); }
|
|
|
|
|
set { SetValue(ButtonLabelProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty ButtonLabelProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(ButtonLabel),
|
2018-06-14 18:38:05 +02:00
|
|
|
|
typeof(string),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
|
|
|
|
new PropertyMetadata("Button", (o, args) => { }));
|
|
|
|
|
|
2018-06-15 10:10:48 +02:00
|
|
|
|
public string DisplayMemberPath
|
|
|
|
|
{
|
|
|
|
|
get { return (string)GetValue(DisplayMemberPathProperty); }
|
|
|
|
|
set { SetValue(DisplayMemberPathProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty DisplayMemberPathProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(DisplayMemberPath),
|
2018-06-15 10:10:48 +02:00
|
|
|
|
typeof(string),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
2018-06-15 18:07:44 +02:00
|
|
|
|
new PropertyMetadata("Title", (o, args) => { }));
|
2018-06-15 10:10:48 +02:00
|
|
|
|
|
2018-06-14 18:38:05 +02:00
|
|
|
|
public object ResizeTarget
|
|
|
|
|
{
|
|
|
|
|
get { return GetValue(ResizeTargetProperty); }
|
|
|
|
|
set { SetValue(ResizeTargetProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty ResizeTargetProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(ResizeTarget),
|
2018-06-14 18:38:05 +02:00
|
|
|
|
typeof(object),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2018-06-15 18:07:44 +02:00
|
|
|
|
public Visibility IsButtonVisible
|
2018-06-15 10:10:48 +02:00
|
|
|
|
{
|
2018-06-15 18:07:44 +02:00
|
|
|
|
get { return (Visibility)GetValue(IsButtonVisibleProperty); }
|
2018-06-15 10:10:48 +02:00
|
|
|
|
set { SetValue(IsButtonVisibleProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty IsButtonVisibleProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(IsButtonVisible),
|
2018-06-15 18:07:44 +02:00
|
|
|
|
typeof(Visibility),
|
2018-06-15 10:10:48 +02:00
|
|
|
|
typeof(HamburgerMenuUserControl),
|
2018-06-15 18:07:44 +02:00
|
|
|
|
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
2018-06-15 10:10:48 +02:00
|
|
|
|
|
2020-03-30 19:43:04 +02:00
|
|
|
|
public IEnumerable<IEntityVm> ItemsSource
|
2018-06-14 18:38:05 +02:00
|
|
|
|
{
|
2020-03-30 19:43:04 +02:00
|
|
|
|
get { return (IEnumerable<IEntityVm>)GetValue(ItemsSourceProperty); }
|
2018-06-14 18:38:05 +02:00
|
|
|
|
set { SetValue(ItemsSourceProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty ItemsSourceProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(ItemsSource),
|
2020-03-30 19:43:04 +02:00
|
|
|
|
typeof(IEnumerable<IEntityVm>),
|
2018-06-14 18:38:05 +02:00
|
|
|
|
typeof(HamburgerMenuUserControl),
|
2020-03-30 19:43:04 +02:00
|
|
|
|
new PropertyMetadata(new List<IEntityVm>(), (o, args) => { }));
|
2018-06-14 18:38:05 +02:00
|
|
|
|
|
2018-06-15 18:07:44 +02:00
|
|
|
|
public object SelectedItem
|
|
|
|
|
{
|
|
|
|
|
get { return GetValue(SelectedItemProperty); }
|
|
|
|
|
set { SetValue(SelectedItemProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SelectedItemProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(SelectedItem),
|
2018-06-15 18:07:44 +02:00
|
|
|
|
typeof(object),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2020-04-16 14:08:50 +02:00
|
|
|
|
public int SelectedIndex
|
|
|
|
|
{
|
|
|
|
|
get { return (int)GetValue(SelectedIndexProperty); }
|
|
|
|
|
set { SetValue(SelectedIndexProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SelectedIndexProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
nameof(SelectedIndex),
|
|
|
|
|
typeof(int),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
|
|
|
|
new PropertyMetadata(-1, (o, args) => { }));
|
|
|
|
|
|
2020-04-07 17:29:03 +02:00
|
|
|
|
public bool IsOpen
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)GetValue(IsOpenProperty); }
|
|
|
|
|
set { SetValue(IsOpenProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty IsOpenProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(IsOpen),
|
2020-04-07 17:29:03 +02:00
|
|
|
|
typeof(bool),
|
|
|
|
|
typeof(HamburgerMenuUserControl),
|
2020-04-16 19:43:17 +02:00
|
|
|
|
new PropertyMetadata(false, (o, args) => { }));
|
2020-04-07 17:29:03 +02:00
|
|
|
|
|
2020-04-28 15:20:47 +02:00
|
|
|
|
public ICommand ActionButtonCommand
|
2018-06-14 18:38:05 +02:00
|
|
|
|
{
|
2020-04-28 15:20:47 +02:00
|
|
|
|
get { return (ICommand)GetValue(ActionButtonCommandProperty); }
|
2020-04-21 13:33:15 +02:00
|
|
|
|
set { SetValue(ActionButtonCommandProperty, value); }
|
2018-06-14 18:38:05 +02:00
|
|
|
|
}
|
2020-04-21 13:33:15 +02:00
|
|
|
|
public static readonly DependencyProperty ActionButtonCommandProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
nameof(ActionButtonCommand),
|
2020-04-28 15:20:47 +02:00
|
|
|
|
typeof(ICommand),
|
2020-04-21 13:33:15 +02:00
|
|
|
|
typeof(HamburgerMenuUserControl),
|
|
|
|
|
new PropertyMetadata(null, (o, args) => { }));
|
|
|
|
|
|
2018-06-14 18:38:05 +02:00
|
|
|
|
|
2020-04-21 13:33:15 +02:00
|
|
|
|
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
|
|
|
|
|
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
2018-06-14 18:38:05 +02:00
|
|
|
|
{
|
2020-04-21 13:33:15 +02:00
|
|
|
|
SelectionChanged?.Invoke(sender, e);
|
2018-06-14 18:38:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|