(WidgetDPK): update key fields in code-behind.

This commit is contained in:
morkt 2015-06-02 16:56:32 +04:00
parent 60f853835e
commit 315aa97e88
5 changed files with 42 additions and 23 deletions

View File

@ -124,6 +124,15 @@ namespace GameRes.Formats.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to 32-bit hex number.
/// </summary>
public static string ArcHex32Bit {
get {
return ResourceManager.GetString("ArcHex32Bit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to no encryption.
/// </summary>

View File

@ -312,6 +312,9 @@ Enter archive encryption key.</value>
<data name="ArcDefault" xml:space="preserve">
<value>Default</value>
</data>
<data name="ArcHex32Bit" xml:space="preserve">
<value>32-bit hex number</value>
</data>
<data name="KCAPDefault" xml:space="preserve">
<value>Default</value>
</data>

View File

@ -136,6 +136,9 @@
<value>Содержимое архива зашифровано.
Выберите алгоритм шифрования.</value>
</data>
<data name="ArcHex32Bit" xml:space="preserve">
<value>32-битное шестнадцатеричное число</value>
</data>
<data name="ArcNoEncryption" xml:space="preserve">
<value>без шифрования</value>
</data>

View File

@ -5,17 +5,6 @@
xmlns:p="clr-namespace:GameRes.Formats.Properties"
xmlns:dac="clr-namespace:GameRes.Formats.Dac"
xmlns:local="clr-namespace:GameRes.Formats.GUI">
<Grid.Resources>
<local:KeyConverter x:Key="keyConverter"/>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition MinWidth="130" Width="*"/>
@ -36,17 +25,10 @@
IsReadOnly="True" TextWrapping="NoWrap" Grid.Column="1" Grid.Row="1" Margin="0,3,0,3"
DataContext="{Binding ElementName=EncScheme, Path=SelectedItem}"/>
<Label Content="{x:Static s:arcStrings.DPKKeys}" Target="{Binding ElementName=Key1}"
ToolTip="{x:Static s:arcStrings.ArcHex32Bit}"
Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right"/>
<TextBox Name="Key1" Grid.Column="1" Grid.Row="2" Margin="0,3,0,3" Width="100" HorizontalAlignment="Left"
DataContext="{Binding ElementName=EncScheme, Path=SelectedItem}">
<TextBox.Text>
<Binding Path="Key1" Mode="OneWay" Converter="{StaticResource keyConverter}" UpdateSourceTrigger="PropertyChanged"/>
</TextBox.Text>
</TextBox>
ToolTip="{x:Static s:arcStrings.ArcHex32Bit}"/>
<TextBox Name="Key2" Grid.Column="1" Grid.Row="3" Margin="0,3,0,3" Width="100" HorizontalAlignment="Left"
DataContext="{Binding ElementName=EncScheme, Path=SelectedItem}">
<TextBox.Text>
<Binding Path="Key2" Mode="OneWay" Converter="{StaticResource keyConverter}" UpdateSourceTrigger="PropertyChanged"/>
</TextBox.Text>
</TextBox>
ToolTip="{x:Static s:arcStrings.ArcHex32Bit}"/>
</Grid>

View File

@ -1,4 +1,6 @@
using System.Windows.Controls;
using GameRes.Formats.Dac;
using GameRes.Formats.Properties;
namespace GameRes.Formats.GUI
{
@ -10,8 +12,28 @@ namespace GameRes.Formats.GUI
public WidgetDPK ()
{
InitializeComponent ();
if (null == EncScheme.SelectedItem)
EncScheme.SelectedIndex = 0;
var last_scheme = EncScheme.SelectedItem as DpkScheme;
if (null == last_scheme)
last_scheme = DpkOpener.KnownSchemes[0];
uint key1 = Settings.Default.DPKKey1;
uint key2 = Settings.Default.DPKKey2;
if (last_scheme.Key1 != key1 || last_scheme.Key2 != key2)
EncScheme.SelectedIndex = -1;
Key1.Text = key1.ToString ("X");
Key2.Text = key2.ToString ("X8");
EncScheme.SelectionChanged += OnSchemeChanged;
}
void OnSchemeChanged (object sender, SelectionChangedEventArgs e)
{
var widget = sender as ComboBox;
var scheme = widget.SelectedItem as DpkScheme;
if (null != scheme)
{
Key1.Text = scheme.Key1.ToString ("X");
Key2.Text = scheme.Key2.ToString ("X8");
}
}
}
}