From 851fe04756f1c2dcfa3cbd94c0c236108a1b5958 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 4 Jan 2018 20:46:37 +0400 Subject: [PATCH] (XP3): display selected decryptor name in popup dialog. --- ArcFormats/KiriKiri/ArcXP3.cs | 2 +- ArcFormats/KiriKiri/WidgetXP3.xaml | 17 ++++++++---- ArcFormats/KiriKiri/WidgetXP3.xaml.cs | 37 ++++++++++++++++++++------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/ArcFormats/KiriKiri/ArcXP3.cs b/ArcFormats/KiriKiri/ArcXP3.cs index 80ce1c71..2a6a71ea 100644 --- a/ArcFormats/KiriKiri/ArcXP3.cs +++ b/ArcFormats/KiriKiri/ArcXP3.cs @@ -98,7 +98,7 @@ namespace GameRes.Formats.KiriKiri public bool ForceEncryptionQuery = true; - private static readonly ICrypt NoCryptAlgorithm = new NoCrypt(); + internal static readonly ICrypt NoCryptAlgorithm = new NoCrypt(); public override ArcFile TryOpen (ArcView file) { diff --git a/ArcFormats/KiriKiri/WidgetXP3.xaml b/ArcFormats/KiriKiri/WidgetXP3.xaml index 831e1919..31e60a30 100644 --- a/ArcFormats/KiriKiri/WidgetXP3.xaml +++ b/ArcFormats/KiriKiri/WidgetXP3.xaml @@ -1,9 +1,16 @@ - - - + xmlns:local="clr-namespace:GameRes.Formats.GUI" + MaxWidth="250" Orientation="Vertical" HorizontalAlignment="Left"> + + + + + + diff --git a/ArcFormats/KiriKiri/WidgetXP3.xaml.cs b/ArcFormats/KiriKiri/WidgetXP3.xaml.cs index 857ff6b9..6fe4c5f4 100644 --- a/ArcFormats/KiriKiri/WidgetXP3.xaml.cs +++ b/ArcFormats/KiriKiri/WidgetXP3.xaml.cs @@ -1,8 +1,9 @@ -using System.Linq; -using System.Windows; +using System; +using System.Collections.Generic; +using System.Linq; using System.Windows.Controls; +using System.Windows.Data; using GameRes.Formats.KiriKiri; -using GameRes.Formats.Properties; using GameRes.Formats.Strings; namespace GameRes.Formats.GUI @@ -10,20 +11,38 @@ namespace GameRes.Formats.GUI /// /// Interaction logic for WidgetXP3.xaml /// - public partial class WidgetXP3 : Grid + public partial class WidgetXP3 : StackPanel { public WidgetXP3 () { InitializeComponent(); - var keys = new string[] { arcStrings.ArcNoEncryption }; - Scheme.ItemsSource = keys.Concat (Xp3Opener.KnownSchemes.Keys.OrderBy (x => x)); - if (-1 == Scheme.SelectedIndex) - Scheme.SelectedIndex = 0; + var keys = new[] { new KeyValuePair (arcStrings.ArcNoEncryption, Xp3Opener.NoCryptAlgorithm) }; + this.DataContext = keys.Concat (Xp3Opener.KnownSchemes.OrderBy (x => x.Key)); + this.Loaded += (s, e) => { + if (-1 == this.Scheme.SelectedIndex) + this.Scheme.SelectedIndex = 0; + }; } 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(); } } }