mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP Top Menu - sort buttons present but not working
Removed flyout from textbox with button Generating a new password creates a new history entry Top Menu edit mode now works as intended
This commit is contained in:
@@ -44,18 +44,6 @@ namespace ModernKeePass.Controls
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(true, (o, args) => { }));
|
||||
|
||||
public FlyoutBase ButtonFlyout
|
||||
{
|
||||
get { return (FlyoutBase)GetValue(ButtonFlyoutProperty); }
|
||||
set { SetValue(ButtonFlyoutProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ButtonFlyoutProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonFlyout",
|
||||
typeof(FlyoutBase),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
@@ -246,9 +246,6 @@
|
||||
Content="{TemplateBinding ButtonSymbol}"
|
||||
IsEnabled="{TemplateBinding IsButtonEnabled}"
|
||||
VerticalAlignment="Stretch">
|
||||
<Button.Flyout>
|
||||
<Flyout Content="{TemplateBinding ButtonFlyout}" />
|
||||
</Button.Flyout>
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{TemplateBinding ButtonTooltip}" />
|
||||
</ToolTipService.ToolTip>
|
||||
|
@@ -447,4 +447,7 @@
|
||||
<data name="TopMenuSaveFlyout.Text" xml:space="preserve">
|
||||
<value>Save</value>
|
||||
</data>
|
||||
<data name="TopMenuSortButton.Content" xml:space="preserve">
|
||||
<value>Sort</value>
|
||||
</data>
|
||||
</root>
|
@@ -447,4 +447,7 @@
|
||||
<data name="TopMenuSaveFlyout.Text" xml:space="preserve">
|
||||
<value>Sauvegarder</value>
|
||||
</data>
|
||||
<data name="TopMenuSortButton.Content" xml:space="preserve">
|
||||
<value>Trier</value>
|
||||
</data>
|
||||
</root>
|
@@ -51,14 +51,14 @@ namespace ModernKeePass.ViewModels
|
||||
public string Name
|
||||
{
|
||||
get { return GetEntryValue(PwDefs.TitleField); }
|
||||
set { SetEntryValue(PwDefs.TitleField, value); }
|
||||
set { SetEntryValue(PwDefs.TitleField, new ProtectedString(true, value)); }
|
||||
}
|
||||
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get { return GetEntryValue(PwDefs.UserNameField); }
|
||||
set { SetEntryValue(PwDefs.UserNameField, value); }
|
||||
set { SetEntryValue(PwDefs.UserNameField, new ProtectedString(true, value)); }
|
||||
}
|
||||
|
||||
public string Password
|
||||
@@ -66,7 +66,7 @@ namespace ModernKeePass.ViewModels
|
||||
get { return GetEntryValue(PwDefs.PasswordField); }
|
||||
set
|
||||
{
|
||||
SetEntryValue(PwDefs.PasswordField, value);
|
||||
SetEntryValue(PwDefs.PasswordField, new ProtectedString(true, value));
|
||||
NotifyPropertyChanged("Password");
|
||||
NotifyPropertyChanged("PasswordComplexityIndicator");
|
||||
}
|
||||
@@ -75,13 +75,13 @@ namespace ModernKeePass.ViewModels
|
||||
public string Url
|
||||
{
|
||||
get { return GetEntryValue(PwDefs.UrlField); }
|
||||
set { SetEntryValue(PwDefs.UrlField, value); }
|
||||
set { SetEntryValue(PwDefs.UrlField, new ProtectedString(true, value)); }
|
||||
}
|
||||
|
||||
public string Notes
|
||||
{
|
||||
get { return GetEntryValue(PwDefs.NotesField); }
|
||||
set { SetEntryValue(PwDefs.NotesField, value); }
|
||||
set { SetEntryValue(PwDefs.NotesField, new ProtectedString(true, value)); }
|
||||
}
|
||||
|
||||
public int IconId
|
||||
@@ -239,7 +239,7 @@ namespace ModernKeePass.ViewModels
|
||||
ProtectedString password;
|
||||
PwGenerator.Generate(out password, pwProfile, null, new CustomPwGeneratorPool());
|
||||
|
||||
_pwEntry?.Strings.Set(PwDefs.PasswordField, password);
|
||||
SetEntryValue(PwDefs.PasswordField, password);
|
||||
NotifyPropertyChanged("Password");
|
||||
NotifyPropertyChanged("IsRevealPasswordEnabled");
|
||||
NotifyPropertyChanged("PasswordComplexityIndicator");
|
||||
@@ -291,14 +291,14 @@ namespace ModernKeePass.ViewModels
|
||||
return _pwEntry?.Strings.GetSafe(key).ReadString();
|
||||
}
|
||||
|
||||
private void SetEntryValue(string key, string newValue)
|
||||
private void SetEntryValue(string key, ProtectedString newValue)
|
||||
{
|
||||
if (!_isDirty)
|
||||
{
|
||||
_pwEntry.Touch(true);
|
||||
_pwEntry?.CreateBackup(null);
|
||||
}
|
||||
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||
_pwEntry?.Strings.Set(key, newValue);
|
||||
_isDirty = true;
|
||||
}
|
||||
}
|
||||
|
@@ -454,6 +454,7 @@
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{Binding UserName}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyLogin" Title="{Binding Name}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:TextBoxWithButton>
|
||||
@@ -463,6 +464,7 @@
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="ButtonClick">
|
||||
<actions:ClipboardAction Text="{Binding Password}" />
|
||||
<actions:ToastAction x:Uid="ToastCopyPassword" Title="{Binding Name}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</local:TextBoxWithButton>
|
||||
@@ -518,6 +520,7 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||
@@ -552,20 +555,48 @@
|
||||
</TextBox>
|
||||
<userControls:BreadCrumbUserControl ItemsSource="{Binding BreadCrumb}" Margin="5,-5,0,0" />
|
||||
</StackPanel>
|
||||
<userControls:TopMenuUserControl
|
||||
x:Name="TopMenu" Grid.Column="2"
|
||||
RestoreButtonVisibility="{Binding ParentGroup.IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
DeleteButtonVisibility="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}"
|
||||
IsEditButtonChecked="{Binding IsEditMode, Mode=TwoWay}"
|
||||
SaveCommand="{Binding SaveCommand}"
|
||||
RestoreCommand="{Binding UndoDeleteCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="DeleteButtonClick">
|
||||
<actions:DeleteEntityAction Entity="{Binding}" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}" />
|
||||
</core:EventTriggerBehavior>
|
||||
<core:EventTriggerBehavior EventName="RestoreButtonClick">
|
||||
<actions:RestoreEntityAction Entity="{Binding}" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</userControls:TopMenuUserControl>
|
||||
</Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup>
|
||||
<VisualState x:Name="Small">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpirationDatePanel" Storyboard.TargetProperty="Orientation">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Vertical"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopMenu" Storyboard.TargetProperty="OverflowButtonsVisibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopMenu" Storyboard.TargetProperty="MoreButtonVisibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Large">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpirationDatePanel" Storyboard.TargetProperty="Orientation">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Horizontal"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Small">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpirationDatePanel" Storyboard.TargetProperty="Orientation">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Vertical"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopMenu" Storyboard.TargetProperty="OverflowButtonsVisibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopMenu" Storyboard.TargetProperty="MoreButtonVisibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
|
@@ -280,10 +280,13 @@
|
||||
<userControls:TopMenuUserControl x:Name="TopMenu" Grid.Column="2"
|
||||
RestoreButtonVisibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
DeleteButtonVisibility="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}"
|
||||
SortButtonVisibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
IsEditButtonChecked="{Binding IsEditMode, Mode=TwoWay}"
|
||||
IsDeleteButtonEnabled="{Binding IsNotRoot}"
|
||||
SaveCommand="{Binding SaveCommand}"
|
||||
RestoreCommand="{Binding UndoDeleteCommand}">
|
||||
RestoreCommand="{Binding UndoDeleteCommand}"
|
||||
SortEntriesCommand="{Binding SortEntriesCommand}"
|
||||
SortGroupsCommand="{Binding SortGroupsCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="DeleteButtonClick">
|
||||
<actions:DeleteEntityAction Entity="{Binding}" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}" />
|
||||
|
@@ -7,7 +7,7 @@
|
||||
mc:Ignorable="d">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Orientation="Horizontal" Visibility="{Binding OverflowButtonsVisibility, ElementName=UserControl}">
|
||||
<Button Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" Click="RestoreButton_Click" Style="{StaticResource NoBorderButtonStyle}" Height="50">
|
||||
<Button Command="{Binding RestoreCommand, ElementName=UserControl}" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" IsEnabled="{Binding IsRestoreButtonEnabled,ElementName=UserControl}" Click="RestoreButton_Click" Style="{StaticResource NoBorderButtonStyle}" Height="50">
|
||||
<SymbolIcon Symbol="Undo">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuRestoreButton" />
|
||||
@@ -28,6 +28,19 @@
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
</ToggleButton>
|
||||
<Button Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
|
||||
<SymbolIcon Symbol="Sort">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuSortButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
</SymbolIcon>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem x:Uid="AppBarSortEntries" Command="{Binding SortEntriesCommand, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="AppBarSortGroups" Command="{Binding SortGroupsCommand, ElementName=UserControl}" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource NoBorderButtonStyle}" Height="50">
|
||||
<SymbolIcon Symbol="Delete">
|
||||
<ToolTipService.ToolTip>
|
||||
@@ -40,10 +53,12 @@
|
||||
<SymbolIcon Symbol="More" />
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Opening="FlyoutBase_OnOpening">
|
||||
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" Click="RestoreButton_Click" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" IsEnabled="{Binding IsRestoreButtonEnabled,ElementName=UserControl}" Click="RestoreButton_Click" Visibility="{Binding RestoreButtonVisibility, 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="AppBarSortEntries" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||
<MenuFlyoutItem x:Uid="AppBarSortGroups" x:Name="SortGroupsFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
|
@@ -55,6 +55,30 @@ namespace ModernKeePass.Views.UserControls
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand SortEntriesCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(SortEntriesCommandProperty); }
|
||||
set { SetValue(SortEntriesCommandProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SortEntriesCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"SortEntriesCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand SortGroupsCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(SortGroupsCommandProperty); }
|
||||
set { SetValue(SortGroupsCommandProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SortGroupsCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
"SortGroupsCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public Visibility RestoreButtonVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(RestoreButtonVisibilityProperty); }
|
||||
@@ -65,7 +89,7 @@ namespace ModernKeePass.Views.UserControls
|
||||
"RestoreButtonVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public Visibility DeleteButtonVisibility
|
||||
{
|
||||
@@ -77,7 +101,7 @@ namespace ModernKeePass.Views.UserControls
|
||||
"DeleteButtonVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public Visibility MoreButtonVisibility
|
||||
{
|
||||
@@ -89,7 +113,7 @@ namespace ModernKeePass.Views.UserControls
|
||||
"MoreButtonVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public Visibility OverflowButtonsVisibility
|
||||
{
|
||||
@@ -101,7 +125,19 @@ namespace ModernKeePass.Views.UserControls
|
||||
"OverflowButtonsVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
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),
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
|
||||
public bool IsDeleteButtonEnabled
|
||||
{
|
||||
@@ -127,6 +163,18 @@ namespace ModernKeePass.Views.UserControls
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(false, (o, args) => { }));
|
||||
|
||||
public bool IsRestoreButtonEnabled
|
||||
{
|
||||
get { return (bool)GetValue(IsRestoreButtonEnabledProperty); }
|
||||
set { SetValue(IsRestoreButtonEnabledProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsRestoreButtonEnabledProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsRestoreButtonEnabled",
|
||||
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;
|
||||
@@ -137,6 +185,13 @@ namespace ModernKeePass.Views.UserControls
|
||||
public TopMenuUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
EditFlyout.Click += EditFlyout_Click;
|
||||
}
|
||||
|
||||
private void EditFlyout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsEditButtonChecked = EditFlyout.IsChecked;
|
||||
EditButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void EditButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -161,7 +216,11 @@ namespace ModernKeePass.Views.UserControls
|
||||
|
||||
EditFlyout.IsChecked = IsEditButtonChecked;
|
||||
|
||||
RestoreFlyout.IsEnabled = IsRestoreButtonEnabled;
|
||||
RestoreFlyout.Visibility = RestoreButtonVisibility;
|
||||
|
||||
SortEntriesFlyout.Visibility = SortButtonVisibility;
|
||||
SortGroupsFlyout.Visibility = SortButtonVisibility;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user