Added dirty behavior

Removed restore action (-> Move action wip)
Added additional check on DB size before auto saving
Code cleanup
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-14 13:44:07 +02:00
parent d972b6cb5a
commit a2eba91a3b
34 changed files with 236 additions and 190 deletions

View File

@@ -21,7 +21,7 @@ namespace ModernKeePass.Views.UserControls
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource",
nameof(ItemsSource),
typeof(IEnumerable<IEntityVm>),
typeof(BreadCrumbUserControl),
new PropertyMetadata(new Stack<IEntityVm>(), (o, args) => { }));

View File

@@ -26,7 +26,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SelectedColorProperty =
DependencyProperty.Register(
"SelectedColor",
nameof(SelectedColor),
typeof(SolidColorBrush),
typeof(ColorPickerUserControl),
new PropertyMetadata(new SolidColorBrush(), (o, args) => { }));

View File

@@ -34,7 +34,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty CreateNewProperty =
DependencyProperty.Register(
"CreateNew",
nameof(CreateNew),
typeof(bool),
typeof(CompositeKeyUserControl),
new PropertyMetadata(false, (o, args) => { }));
@@ -46,7 +46,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty UpdateKeyProperty =
DependencyProperty.Register(
"UpdateKey",
nameof(UpdateKey),
typeof(bool),
typeof(CompositeKeyUserControl),
new PropertyMetadata(false, (o, args) => { }));
@@ -58,7 +58,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty ButtonLabelProperty =
DependencyProperty.Register(
"ButtonLabel",
nameof(ButtonLabel),
typeof(string),
typeof(CompositeKeyUserControl),
new PropertyMetadata("OK", (o, args) => { }));
@@ -70,7 +70,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty DatabaseFilePathProperty =
DependencyProperty.Register(
"DatabaseFilePath",
nameof(DatabaseFilePath),
typeof(string),
typeof(CompositeKeyUserControl),
new PropertyMetadata(null, (o, args) => { }));

View File

@@ -23,7 +23,6 @@
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
<ListView.Resources>
<x:Double x:Key="HamburgerMenuSize">300</x:Double>
<DataTemplate x:Name="IsSpecial">
<StackPanel Orientation="Horizontal">
<SymbolIcon Symbol="{Binding Icon, Converter={StaticResource IconToSymbolConverter}, ConverterParameter=48}" Margin="7,15,0,15">
@@ -51,13 +50,13 @@
<ListView.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ToggleButton Style="{StaticResource HamburgerToggleButton}" IsChecked="{Binding Path={Binding IsOpen, ElementName=UserControl}}">
<ToggleButton Style="{StaticResource HamburgerToggleButton}" IsChecked="{Binding IsOpen, ElementName=UserControl}">
<ToolTipService.ToolTip>
<ToolTip Content="{Binding HeaderLabel, ElementName=UserControl}" />
</ToolTipService.ToolTip>
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Checked">
<core:ChangePropertyAction PropertyName="Width" Value="{StaticResource HamburgerMenuSize}" TargetObject="{Binding ResizeTarget, ElementName=UserControl}"/>
<core:ChangePropertyAction PropertyName="Width" Value="{StaticResource ExpandedMenuSize}" TargetObject="{Binding ResizeTarget, ElementName=UserControl}"/>
</core:EventTriggerBehavior>
<core:EventTriggerBehavior EventName="Unchecked">
<core:ChangePropertyAction PropertyName="Width" Value="{StaticResource MenuSize}" TargetObject="{Binding ResizeTarget, ElementName=UserControl}"/>
@@ -72,7 +71,7 @@
<DataTemplate>
<StackPanel Orientation="Vertical">
<Border BorderBrush="White" BorderThickness="0,0,0,1" />
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Visibility="{Binding IsButtonVisible, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource HamburgerMenuSize}" HorizontalContentAlignment="Left" Click="ButtonBase_OnClick">
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Visibility="{Binding IsButtonVisible, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource ExpandedMenuSize}" HorizontalContentAlignment="Left" Click="ButtonBase_OnClick">
<StackPanel Orientation="Horizontal" Margin="17,0,5,0">
<SymbolIcon Symbol="Add">
<ToolTipService.ToolTip>
@@ -82,7 +81,7 @@
<TextBlock Text="{Binding ButtonLabel, ElementName=UserControl}" FontWeight="SemiBold" TextWrapping="NoWrap" FontSize="16" VerticalAlignment="Center" Margin="30,0,20,0" />
</StackPanel>
</Button>
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource HamburgerMenuSize}" HorizontalContentAlignment="Left">
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource ExpandedMenuSize}" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal" Margin="17,0,5,0">
<SymbolIcon Symbol="Home">
<ToolTipService.ToolTip>
@@ -97,7 +96,7 @@
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource HamburgerMenuSize}" HorizontalContentAlignment="Left">
<Button Padding="0" Height="{StaticResource MenuSize}" Margin="0" Style="{StaticResource NoBorderButtonStyle}" Background="Transparent" BorderThickness="0" Width="{StaticResource ExpandedMenuSize}" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal" Margin="17,0,5,0">
<SymbolIcon Symbol="Setting">
<ToolTipService.ToolTip>

View File

@@ -22,7 +22,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty HeaderLabelProperty =
DependencyProperty.Register(
"HeaderLabel",
nameof(HeaderLabel),
typeof(string),
typeof(HamburgerMenuUserControl),
new PropertyMetadata("Header", (o, args) => { }));
@@ -34,7 +34,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty ButtonLabelProperty =
DependencyProperty.Register(
"ButtonLabel",
nameof(ButtonLabel),
typeof(string),
typeof(HamburgerMenuUserControl),
new PropertyMetadata("Button", (o, args) => { }));
@@ -46,7 +46,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty DisplayMemberPathProperty =
DependencyProperty.Register(
"DisplayMemberPath",
nameof(DisplayMemberPath),
typeof(string),
typeof(HamburgerMenuUserControl),
new PropertyMetadata("Title", (o, args) => { }));
@@ -58,7 +58,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty ResizeTargetProperty =
DependencyProperty.Register(
"ResizeTarget",
nameof(ResizeTarget),
typeof(object),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
@@ -70,7 +70,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty IsButtonVisibleProperty =
DependencyProperty.Register(
"IsButtonVisible",
nameof(IsButtonVisible),
typeof(Visibility),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
@@ -83,7 +83,7 @@ namespace ModernKeePass.Views.UserControls
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource",
nameof(ItemsSource),
typeof(IEnumerable<IEntityVm>),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(new List<IEntityVm>(), (o, args) => { }));
@@ -95,7 +95,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SelectedItemProperty =
DependencyProperty.Register(
"SelectedItem",
nameof(SelectedItem),
typeof(object),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
@@ -107,10 +107,10 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.Register(
"IsOpen",
nameof(IsOpen),
typeof(bool),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(false, (o, args) => { }));
new PropertyMetadata(true, (o, args) => { }));
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)

View File

@@ -19,7 +19,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SelectedSymbolProperty =
DependencyProperty.Register(
"SelectedSymbol",
nameof(SelectedSymbol),
typeof(Symbol),
typeof(SymbolPickerUserControl),
new PropertyMetadata(Symbol.Stop, (o, args) => { }));

View File

@@ -42,10 +42,10 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<StackPanel x:Name="OverflowButtons" Orientation="Horizontal">
<Button Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Click="RestoreButton_Click" Style="{StaticResource MenuButtonStyle}">
<Button Command="{Binding MoveCommand, ElementName=UserControl}" IsEnabled="{Binding IsMoveButtonEnabled, ElementName=UserControl}" Click="MoveButton_Click" Style="{StaticResource MenuButtonStyle}">
<SymbolIcon Symbol="Undo">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuRestoreButton" />
<ToolTip x:Uid="TopMenuMoveButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</Button>
@@ -76,7 +76,7 @@
</ToolTipService.ToolTip>
</SymbolIcon>
</ToggleButton>
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource MenuButtonStyle}">
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource MenuButtonStyle}">
<SymbolIcon Symbol="Delete">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuDeleteButton" />
@@ -88,10 +88,10 @@
<SymbolIcon Symbol="More" />
<Button.Flyout>
<MenuFlyout Opening="OverflowFlyout_OnOpening">
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Click="RestoreButton_Click" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuMoveFlyout" x:Name="MoveFlyout" Command="{Binding MoveCommand, ElementName=UserControl}" Click="MoveButton_Click" IsEnabled="{Binding IsMoveButtonEnabled, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" />
<ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" />
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" Click="DeleteButton_Click" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" Click="DeleteButton_Click" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuSortGroupsFlyout" x:Name="SortGroupsFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
</MenuFlyout>

View File

@@ -15,7 +15,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SaveCommandProperty =
DependencyProperty.Register(
"SaveCommand",
nameof(SaveCommand),
typeof(ICommand),
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
@@ -27,7 +27,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty EditCommandProperty =
DependencyProperty.Register(
"EditCommand",
nameof(EditCommand),
typeof(ICommand),
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
@@ -39,19 +39,19 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty DeleteCommandProperty =
DependencyProperty.Register(
"DeleteCommand",
nameof(DeleteCommand),
typeof(ICommand),
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
public ICommand RestoreCommand
public ICommand MoveCommand
{
get { return (ICommand)GetValue(RestoreCommandProperty); }
set { SetValue(RestoreCommandProperty, value); }
get { return (ICommand)GetValue(MoveCommandProperty); }
set { SetValue(MoveCommandProperty, value); }
}
public static readonly DependencyProperty RestoreCommandProperty =
public static readonly DependencyProperty MoveCommandProperty =
DependencyProperty.Register(
"RestoreCommand",
nameof(MoveCommand),
typeof(ICommand),
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
@@ -63,7 +63,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SortEntriesCommandProperty =
DependencyProperty.Register(
"SortEntriesCommand",
nameof(SortEntriesCommand),
typeof(ICommand),
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
@@ -75,34 +75,22 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SortGroupsCommandProperty =
DependencyProperty.Register(
"SortGroupsCommand",
nameof(SortGroupsCommand),
typeof(ICommand),
typeof(TopMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
public Visibility RestoreButtonVisibility
public bool IsMoveButtonEnabled
{
get { return (Visibility)GetValue(RestoreButtonVisibilityProperty); }
set { SetValue(RestoreButtonVisibilityProperty, value); }
get { return (bool)GetValue(IsMoveButtonEnabledProperty); }
set { SetValue(IsMoveButtonEnabledProperty, value); }
}
public static readonly DependencyProperty RestoreButtonVisibilityProperty =
public static readonly DependencyProperty IsMoveButtonEnabledProperty =
DependencyProperty.Register(
"RestoreButtonVisibility",
typeof(Visibility),
nameof(IsMoveButtonEnabled),
typeof(bool),
typeof(TopMenuUserControl),
new PropertyMetadata(Visibility.Collapsed, (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(Visibility.Collapsed, (o, args) => { }));
new PropertyMetadata(true, (o, args) => { }));
public Visibility SortButtonVisibility
{
@@ -111,7 +99,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty SortButtonVisibilityProperty =
DependencyProperty.Register(
"SortButtonVisibility",
nameof(SortButtonVisibility),
typeof(Visibility),
typeof(TopMenuUserControl),
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
@@ -123,7 +111,7 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty IsDeleteButtonEnabledProperty =
DependencyProperty.Register(
"IsDeleteButtonEnabled",
nameof(IsDeleteButtonEnabled),
typeof(bool),
typeof(TopMenuUserControl),
new PropertyMetadata(true, (o, args) => { }));
@@ -135,14 +123,14 @@ namespace ModernKeePass.Views.UserControls
}
public static readonly DependencyProperty IsEditButtonCheckedProperty =
DependencyProperty.Register(
"IsEditButtonChecked",
nameof(IsEditButtonChecked),
typeof(bool),
typeof(TopMenuUserControl),
new PropertyMetadata(false, (o, args) => { }));
public event EventHandler<RoutedEventArgs> EditButtonClick;
public event EventHandler<RoutedEventArgs> DeleteButtonClick;
public event EventHandler<RoutedEventArgs> RestoreButtonClick;
public event EventHandler<RoutedEventArgs> MoveButtonClick;
public TopMenuUserControl()
{
@@ -166,19 +154,19 @@ namespace ModernKeePass.Views.UserControls
DeleteButtonClick?.Invoke(sender, e);
}
private void RestoreButton_Click(object sender, RoutedEventArgs e)
private void MoveButton_Click(object sender, RoutedEventArgs e)
{
RestoreButtonClick?.Invoke(sender, e);
MoveButtonClick?.Invoke(sender, e);
}
private void OverflowFlyout_OnOpening(object sender, object e)
{
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
DeleteFlyout.Visibility = DeleteButtonVisibility;
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
EditFlyout.IsChecked = IsEditButtonChecked;
RestoreFlyout.Visibility = RestoreButtonVisibility;
MoveFlyout.IsEnabled = IsMoveButtonEnabled;
SortEntriesFlyout.Visibility = SortButtonVisibility;
SortGroupsFlyout.Visibility = SortButtonVisibility;