Skip to content

Commit

Permalink
Add key generation dialog on secret favorite opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Apr 3, 2024
1 parent 283f026 commit 0c7cf48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions KeyManager.Library.UI/OpenFavoriteControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,40 @@
xmlns="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http:https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008"
xmlns:domain="clr-namespace:Leosac.KeyManager.Library.UI.Domain"
xmlns:local="clr-namespace:Leosac.KeyManager.Library.UI"
xmlns:materialDesign="http:https://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:properties="clr-namespace:Leosac.KeyManager.Library.UI.Properties"
mc:Ignorable="d"
d:DesignHeight="150" d:DesignWidth="290">
<StackPanel Margin="16" Width="250">
d:DesignHeight="150" d:DesignWidth="390">
<UserControl.Resources>
<domain:HexStringLengthConverter x:Key="HexStringLengthConverter" />
</UserControl.Resources>
<StackPanel Margin="16" Width="350">
<Label Content="{Binding Path=Title, ElementName=favControl}" Margin="5" />
<PasswordBox materialDesign:HintAssist.HelperText="{x:Static properties:Resources.SecretHelper}"
<DockPanel>
<WrapPanel DockPanel.Dock="Right" VerticalAlignment="Center">
<materialDesign:DialogHost Identifier="KeyGenerationDialog" DialogTheme="Inherit">
<materialDesign:DialogHost.DialogContent>
<local:SymmetricKeyGenerationDialog KeySize="{Binding Path=Properties.SecretMaxLength, Mode=OneWay, Converter={StaticResource HexStringLengthConverter}, ElementName=favControl}" KeyValue="{Binding Properties.Secret, Mode=TwoWay, ElementName=favControl}" />
</materialDesign:DialogHost.DialogContent>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"
Width="24" Height="24" Margin="2"
ToolTip="{x:Static properties:Resources.KeyGeneration}">
<materialDesign:PackIcon Kind="Seedling" Height="16" Width="16"/>
</Button>
</materialDesign:DialogHost>
</WrapPanel>
<PasswordBox materialDesign:HintAssist.HelperText="{x:Static properties:Resources.SecretHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.Secret}"
materialDesign:TextFieldAssist.HasClearButton="True" Margin="5"
materialDesign:TextFieldAssist.CharacterCounterVisibility="Visible"
Style="{StaticResource MaterialDesignFloatingHintRevealPasswordBox}"
materialDesign:PasswordBoxAssist.Password="{Binding Properties.Secret, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ElementName=favControl}"
MaxLength="{Binding Properties.SecretMaxLength, Mode=OneWay, ElementName=favControl}"
Visibility="{Binding Properties.StoreSecret, Converter={StaticResource InverseBooleanToVisibilityConverter}, ElementName=favControl}"/>
</DockPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="0,8,8,0" CommandParameter="{Binding}" Command="{Binding Command, ElementName=favControl}" Content="{x:Static properties:Resources.OK}" IsDefault="True" Style="{StaticResource MaterialDesignFlatButton}" />
<Button Margin="0,8,8,0" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Content="{x:Static properties:Resources.Cancel}" IsCancel="True" Style="{StaticResource MaterialDesignFlatButton}" />
Expand Down
2 changes: 1 addition & 1 deletion KeyManager/Domain/EditKeyStoreControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public static async Task<bool> AskForKeyStoreSecretIfRequired(KeyStore ks)
var dialog = new OpenFavoriteControl
{
DataContext = ks,
Properties = ks.Properties,
Properties = ks.Properties!,
Title = string.Format("{0} - {1}", Properties.Resources.OpenFavorite, ks.Name),
Command = new RelayCommand(() =>
{
Expand Down

0 comments on commit 0c7cf48

Please sign in to comment.