Added DataTrigger on generate password button to close flyout

This commit is contained in:
2017-10-19 17:23:56 +02:00
committed by BONNEVILLE Geoffroy
parent 54ad395d13
commit 6548d1d9c1
4 changed files with 44 additions and 19 deletions

View File

@@ -0,0 +1,17 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Xaml.Interactivity;
namespace ModernKeePass.Actions
{
public class CloseFlyoutAction : DependencyObject, IAction
{
public object Execute(object sender, object parameter)
{
var flyout = sender as Flyout;
flyout?.Hide();
return null;
}
}
}

View File

@@ -107,6 +107,7 @@
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Actions\CloseFlyoutAction.cs" />
<Compile Include="Actions\SetupFocusAction.cs" /> <Compile Include="Actions\SetupFocusAction.cs" />
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>

View File

@@ -6,6 +6,8 @@
xmlns:viewModels="using:ModernKeePass.ViewModels" xmlns:viewModels="using:ModernKeePass.ViewModels"
xmlns:converters="using:ModernKeePass.Converters" xmlns:converters="using:ModernKeePass.Converters"
xmlns:local="using:ModernKeePass.Controls" xmlns:local="using:ModernKeePass.Controls"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Actions="using:ModernKeePass.Actions"
x:Name="PageRoot" x:Name="PageRoot"
x:Class="ModernKeePass.Pages.EntryDetailPage" x:Class="ModernKeePass.Pages.EntryDetailPage"
mc:Ignorable="d"> mc:Ignorable="d">
@@ -315,7 +317,7 @@
Visibility="Collapsed" Visibility="Collapsed"
FontSize="{TemplateBinding FontSize}" FontSize="{TemplateBinding FontSize}"
VerticalAlignment="Stretch"/> VerticalAlignment="Stretch"/>
<Button x:Name="GeneratorButton" <Button
Grid.Row="1" Grid.Row="1"
Style="{StaticResource GeneratorButtonStyle}" Style="{StaticResource GeneratorButtonStyle}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
@@ -325,20 +327,28 @@
FontSize="{TemplateBinding FontSize}" FontSize="{TemplateBinding FontSize}"
VerticalAlignment="Stretch" > VerticalAlignment="Stretch" >
<Button.Flyout> <Button.Flyout>
<Flyout> <Flyout x:Name="GenerateButtonFlyout">
<Interactivity:Interaction.Behaviors>
<Core:DataTriggerBehavior Binding="{Binding Password}" ComparisonCondition="NotEqual" Value="" >
<Actions:CloseFlyoutAction />
</Core:DataTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<StackPanel> <StackPanel>
<TextBlock>Password Length:</TextBlock> <TextBlock>
<Run Text="Password Length:"/>
</TextBlock>
<Slider Value="{Binding PasswordLength, Mode=TwoWay}" Margin="0,-10,0,-20" /> <Slider Value="{Binding PasswordLength, Mode=TwoWay}" Margin="0,-10,0,-20" />
<CheckBox IsChecked="{Binding UpperCasePatternSelected, Mode=TwoWay}">Upper case (A, B, C, ...)</CheckBox> <CheckBox IsChecked="{Binding UpperCasePatternSelected, Mode=TwoWay}" Content="Upper case (A, B, C, ...)"/>
<CheckBox IsChecked="{Binding LowerCasePatternSelected, Mode=TwoWay}">Lower case (a, b, c, ...)</CheckBox> <CheckBox IsChecked="{Binding LowerCasePatternSelected, Mode=TwoWay}" Content="Lower case (a, b, c, ...)"/>
<CheckBox IsChecked="{Binding DigitsPatternSelected, Mode=TwoWay}">Digits (0, 1, 2, ...)</CheckBox> <CheckBox IsChecked="{Binding DigitsPatternSelected, Mode=TwoWay}" Content="Digits (0, 1, 2, ...)"/>
<CheckBox IsChecked="{Binding MinusPatternSelected, Mode=TwoWay}">Minus (-)</CheckBox> <CheckBox IsChecked="{Binding MinusPatternSelected, Mode=TwoWay}" Content="Minus (-)"/>
<CheckBox IsChecked="{Binding UnderscorePatternSelected, Mode=TwoWay}">Underscore (_)</CheckBox> <CheckBox IsChecked="{Binding UnderscorePatternSelected, Mode=TwoWay}" Content="Underscore (_)"/>
<CheckBox IsChecked="{Binding SpacePatternSelected, Mode=TwoWay}">Space ( )</CheckBox> <CheckBox IsChecked="{Binding SpacePatternSelected, Mode=TwoWay}" Content="Space ( )"/>
<CheckBox IsChecked="{Binding SpecialPatternSelected, Mode=TwoWay}">Special (!, $, %, ...)</CheckBox> <CheckBox IsChecked="{Binding SpecialPatternSelected, Mode=TwoWay}" Content="Special (!, $, %, ...)"/>
<CheckBox IsChecked="{Binding BracketsPatternSelected, Mode=TwoWay}">Brackets ([], {}, (), ...)</CheckBox> <CheckBox IsChecked="{Binding BracketsPatternSelected, Mode=TwoWay}" Content="Brackets ([], {}, (), ...)"/>
<Button Click="PasswordGenerationButton_Click">Generate</Button> <Button Click="PasswordGenerationButton_Click" Content="Generate"/>
</StackPanel> </StackPanel>
</Flyout> </Flyout>
</Button.Flyout> </Button.Flyout>
</Button> </Button>
@@ -384,15 +394,15 @@
<local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" GotoClick="UrlButton_Click" /> <local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" GotoClick="UrlButton_Click" />
<TextBlock TextWrapping="Wrap" Text="Notes" FontSize="18"/> <TextBlock TextWrapping="Wrap" Text="Notes" FontSize="18"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Notes, Mode=TwoWay}" Width="350" Height="200" AcceptsReturn="True" IsSpellCheckEnabled="True" /> <TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Notes, Mode=TwoWay}" Width="350" Height="200" AcceptsReturn="True" IsSpellCheckEnabled="True" />
<CheckBox FontSize="18" IsChecked="{Binding HasExpirationDate, Mode=TwoWay}">Expiration date</CheckBox> <CheckBox FontSize="18" IsChecked="{Binding HasExpirationDate, Mode=TwoWay}" Content="Expiration date"/>
<StackPanel Orientation="Horizontal" IsHitTestVisible="{Binding HasExpirationDate}"> <StackPanel Orientation="Horizontal" IsHitTestVisible="{Binding HasExpirationDate}">
<SymbolIcon Symbol="Important" Foreground="DarkRed" Visibility="{Binding HasExpired, Converter={StaticResource BooleanToVisibilityConverter}}"> <SymbolIcon Symbol="Important" Foreground="DarkRed" Visibility="{Binding HasExpired, Converter={StaticResource BooleanToVisibilityConverter}}">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
<ToolTip Content="Password has expired" /> <ToolTip Content="Password has expired" />
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</SymbolIcon> </SymbolIcon>
<DatePicker Margin="0,0,20,0" Date="{Binding ExpiryDate, Mode=TwoWay}" ></DatePicker> <DatePicker Margin="0,0,20,0" Date="{Binding ExpiryDate, Mode=TwoWay}" />
<TimePicker Time="{Binding ExpiryTime, Mode=TwoWay}"></TimePicker> <TimePicker Time="{Binding ExpiryTime, Mode=TwoWay}"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@@ -426,4 +436,4 @@
</CommandBar> </CommandBar>
</Grid> </Grid>
</Grid> </Grid>
</Page> </Page>

View File

@@ -7,7 +7,6 @@ using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common; using ModernKeePass.Common;
using ModernKeePass.ViewModels; using ModernKeePass.ViewModels;
using ModernKeePassLib.Cryptography.PasswordGenerator;
// Pour en savoir plus sur le modèle d'élément Page Détail de l'élément, consultez la page http://go.microsoft.com/fwlink/?LinkId=234232 // Pour en savoir plus sur le modèle d'élément Page Détail de l'élément, consultez la page http://go.microsoft.com/fwlink/?LinkId=234232
@@ -118,8 +117,6 @@ namespace ModernKeePass.Pages
private void PasswordGenerationButton_Click(object sender, RoutedEventArgs e) private void PasswordGenerationButton_Click(object sender, RoutedEventArgs e)
{ {
Model.GeneratePassword(); Model.GeneratePassword();
/*var button = (Button)sender;
button?.Flyout?.Hide();*/
} }
} }
} }