(XP3): display selected decryptor name in popup dialog.

This commit is contained in:
morkt
2018-01-04 20:46:37 +04:00
parent d87ac53f9b
commit 851fe04756
3 changed files with 41 additions and 15 deletions

View File

@@ -98,7 +98,7 @@ namespace GameRes.Formats.KiriKiri
public bool ForceEncryptionQuery = true; public bool ForceEncryptionQuery = true;
private static readonly ICrypt NoCryptAlgorithm = new NoCrypt(); internal static readonly ICrypt NoCryptAlgorithm = new NoCrypt();
public override ArcFile TryOpen (ArcView file) public override ArcFile TryOpen (ArcView file)
{ {

View File

@@ -1,9 +1,16 @@
<Grid x:Class="GameRes.Formats.GUI.WidgetXP3" <StackPanel x:Class="GameRes.Formats.GUI.WidgetXP3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fmt="clr-namespace:GameRes.Formats.KiriKiri" xmlns:fmt="clr-namespace:GameRes.Formats.KiriKiri"
xmlns:p="clr-namespace:GameRes.Formats.Properties" xmlns:p="clr-namespace:GameRes.Formats.Properties"
MaxWidth="250"> xmlns:local="clr-namespace:GameRes.Formats.GUI"
<ComboBox Name="Scheme" ItemsSource="{Binding}" MaxWidth="250" Orientation="Vertical" HorizontalAlignment="Left">
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=XP3Scheme, Mode=TwoWay}" Width="180"/> <StackPanel.Resources>
</Grid> <local:ClassNameConverter x:Key="ClassNameConverter" />
</StackPanel.Resources>
<ComboBox Name="Scheme" Width="180" ItemsSource="{Binding}" HorizontalAlignment="Left"
DisplayMemberPath="Key" SelectedValuePath="Key"
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=XP3Scheme, Mode=TwoWay}"/>
<TextBlock Name="AlgorithmName" DataContext="{Binding ElementName=Scheme, Path=SelectedItem}" Margin="0,5,0,0"
Text="{Binding Path=Value, Mode=OneWay, Converter={StaticResource ClassNameConverter}}"/>
</StackPanel>

View File

@@ -1,8 +1,9 @@
using System.Linq; using System;
using System.Windows; using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using GameRes.Formats.KiriKiri; using GameRes.Formats.KiriKiri;
using GameRes.Formats.Properties;
using GameRes.Formats.Strings; using GameRes.Formats.Strings;
namespace GameRes.Formats.GUI namespace GameRes.Formats.GUI
@@ -10,20 +11,38 @@ namespace GameRes.Formats.GUI
/// <summary> /// <summary>
/// Interaction logic for WidgetXP3.xaml /// Interaction logic for WidgetXP3.xaml
/// </summary> /// </summary>
public partial class WidgetXP3 : Grid public partial class WidgetXP3 : StackPanel
{ {
public WidgetXP3 () public WidgetXP3 ()
{ {
InitializeComponent(); InitializeComponent();
var keys = new string[] { arcStrings.ArcNoEncryption }; var keys = new[] { new KeyValuePair<string, ICrypt> (arcStrings.ArcNoEncryption, Xp3Opener.NoCryptAlgorithm) };
Scheme.ItemsSource = keys.Concat (Xp3Opener.KnownSchemes.Keys.OrderBy (x => x)); this.DataContext = keys.Concat (Xp3Opener.KnownSchemes.OrderBy (x => x.Key));
if (-1 == Scheme.SelectedIndex) this.Loaded += (s, e) => {
Scheme.SelectedIndex = 0; if (-1 == this.Scheme.SelectedIndex)
this.Scheme.SelectedIndex = 0;
};
} }
public ICrypt GetScheme () public ICrypt GetScheme ()
{ {
return Xp3Opener.GetScheme (Scheme.SelectedItem as string); return Xp3Opener.GetScheme (Scheme.SelectedValue as string);
}
}
internal class ClassNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null)
return value.GetType().Name;
else
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
} }
} }
} }