-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
SymmetricKeyControl.xaml
96 lines (95 loc) · 7.47 KB
/
SymmetricKeyControl.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<UserControl x:Class="Leosac.KeyManager.Library.UI.SymmetricKeyControl"
x:Name="keyControl"
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: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"
xmlns:wpfappdomain="clr-namespace:Leosac.WpfApp.Domain;assembly=WpfApp"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="500">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack:https://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary Source="pack:https://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
</ResourceDictionary.MergedDictionaries>
<wpfappdomain:ByteLengthToCharLengthConverter x:Key="ByteLengthToCharLengthConverter" />
<domain:KeyChecksumConverter x:Key="KeyChecksumConverter" />
<domain:NullToBooleanConverter x:Key="NullToBooleanConverter" />
<s:Boolean x:Key="True">True</s:Boolean>
</ResourceDictionary>
</UserControl.Resources>
<DockPanel LastChildFill="True">
<local:KeyActionButtonsControl DockPanel.Dock="Top" Key="{Binding Path=Key, ElementName=keyControl}"
ShowKeyLink="{Binding Path=ShowKeyLink, ElementName=keyControl}"
KClass="Symmetric" HorizontalAlignment="Right" />
<ListBox ItemsSource="{Binding Path=Key.Materials, ElementName=keyControl}" HorizontalContentAlignment="Stretch"
IsEnabled="{Binding Path=Key.Link.KeyStoreFavorite, ElementName=keyControl, Converter={StaticResource NullToBooleanConverter}, ConverterParameter={StaticResource True}}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Right" Text="{Binding Name}" />
<DockPanel Grid.Row="1" LastChildFill="True" Visibility="{Binding IsRealKeyMateriel, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
<TextBox Margin="0,5,0,20" MinWidth="350"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.GenericValue}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.GenericValue}"
MaxLength="{Binding Path=OverrideSize, Converter={StaticResource ByteLengthToCharLengthConverter}}"
Text="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"/>
</DockPanel>
<DockPanel Grid.Row="1" LastChildFill="True" Visibility="{Binding IsRealKeyMateriel, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" x:Name="tbxKCV" Margin="0,5,0,5"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.KCVHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.KCV}"
Visibility="{Binding ShowKCV, ElementName=keyControl, Converter={StaticResource BooleanToVisibilityConverter}}"
IsReadOnly="True">
<TextBox.Text>
<MultiBinding Converter="{StaticResource KeyChecksumConverter}" Mode="OneWay">
<Binding Path="SelectedKeyChecksumAlgorithm" ElementName="keyControl" />
<Binding Path="Key" ElementName="keyControl" />
<Binding Path="KeyChecksumIV" ElementName="keyControl" />
<Binding Path="Value" />
</MultiBinding>
</TextBox.Text>
</TextBox>
<ComboBox Grid.Column="1" Margin="0,5,0,5"
ItemsSource="{Binding Path=KeyChecksumAlgorithms, Mode=OneWay, ElementName=keyControl}"
SelectedItem="{Binding Path=SelectedKeyChecksumAlgorithm, Mode=TwoWay, ElementName=keyControl}"
Visibility="{Binding ShowKCV, ElementName=keyControl, Converter={StaticResource BooleanToVisibilityConverter}}"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.KCVAlgorithmHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.KCVAlgorithm}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<PasswordBox Margin="0,5,0,20" Grid.Row="0" Grid.ColumnSpan="2" MinWidth="350"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.KeyValueHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.KeyValue}"
materialDesign:TextFieldAssist.HasClearButton="True"
materialDesign:TextFieldAssist.CharacterCounterVisibility="Visible"
MaxLength="{Binding Path=Key.KeySize, Converter={StaticResource ByteLengthToCharLengthConverter}, ElementName=keyControl}"
Style="{StaticResource MaterialDesignFloatingHintRevealPasswordBox}"
materialDesign:PasswordBoxAssist.Password="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" />
</DockPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</UserControl>