Skip to content

Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.

C#

Languages: enum combos and the run status line follow a language switch

Alexander Graefd3ac0d85cd0a
diff --git a/CLAUDE.md b/CLAUDE.md
index e1b3802..ee2198d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -209,7 +209,11 @@ WPF shell as it stands:
French). The Properties
pane is localised through generated keys: `Label.<Type>.<Member>`, `Hint.<Type>.<Member>` and
`Enum.<Type>.<Member>`; the `meta:Label`/`meta:Hint` extensions return a `DynamicResource` when
- the key exists (live) and the attribute text otherwise, `EnumNameConverter` looks the key up first.
+ the key exists (live) and the attribute text otherwise, `EnumNameConverter` looks the key up first. A converter's output does not follow a
+ language switch by itself: the enum combos' item template and the status bar's run line bind the current
+ language (`LanguageController.Instance.Current`) as an extra input of a `MultiBinding`, so they re-read
+ their words (2026-10-15, after "Intensiteit" and "Abgeschlossen" stayed on after a switch back; UI
+ Automation does not expose a combo's selection text, so a `PrintWindow` capture was the proof).
The model's `DisplayName`/`Description` attributes stay the English source; `_tools/…` is not
needed: the generator was a one-off script, the English block in `Strings.EN.xaml` is what the
attributes said on 2026-10-14. **Adding a model property means adding its keys to all four
diff --git a/WaveDude.WPF/Converters/EnumNameConverter.cs b/WaveDude.WPF/Converters/EnumNameConverter.cs
index 123f521..9c62d68 100644
--- a/WaveDude.WPF/Converters/EnumNameConverter.cs
+++ b/WaveDude.WPF/Converters/EnumNameConverter.cs
@@ -7,9 +7,22 @@ using System.Windows.Data;
namespace WaveDude.WPF.Converters;
-/// <summary>Shows an enum value as words: <c>SmoothedSquare</c> becomes "Smoothed square".</summary>
-public sealed partial class EnumNameConverter : IValueConverter
+/// <summary>
+/// Shows an enum value as words: the string table's <c>Enum.Type.Member</c> entry, else a [Description], else
+/// <c>SmoothedSquare</c> becomes "Smoothed square". As a multi-value converter it takes the value and, as a
+/// second input, the current language, so a bound text is re-read on a language switch (the Kind combo kept
+/// "Intensiteit" after a switch back to English, 2026-10-15).
+/// </summary>
+public sealed partial class EnumNameConverter : IValueConverter, IMultiValueConverter
{
+ /// <inheritdoc/>
+ public object? Convert(object?[] values, Type targetType, object? parameter, CultureInfo culture) =>
+ values.Length > 0 ? Convert(values[0], targetType, parameter, culture) : null;
+
+ /// <inheritdoc/>
+ public object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) =>
+ throw new NotSupportedException();
+
[GeneratedRegex("(?<=[a-z0-9])(?=[A-Z])")]
private static partial Regex WordBoundary();
diff --git a/WaveDude.WPF/MainWindow.xaml b/WaveDude.WPF/MainWindow.xaml
index 49be8c6..6d4f467 100644
--- a/WaveDude.WPF/MainWindow.xaml
+++ b/WaveDude.WPF/MainWindow.xaml
@@ -250,6 +250,8 @@
<Binding Path="Run.TotalSteps" />
<Binding Path="Run.EngineDescription" />
<Binding Path="IsRunStale" />
+ <!-- the language, so the words follow a switch (the status kept "Abgeschlossen" after one, 2026-10-15) -->
+ <Binding Path="Current" Source="{x:Static localization:LanguageController.Instance}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
diff --git a/WaveDude.WPF/Themes/Editors.xaml b/WaveDude.WPF/Themes/Editors.xaml
index 6155b60..5603a7e 100644
--- a/WaveDude.WPF/Themes/Editors.xaml
+++ b/WaveDude.WPF/Themes/Editors.xaml
@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:WaveDude.WPF.Converters"
- xmlns:controls="clr-namespace:WaveDude.WPF.Controls">
+ xmlns:controls="clr-namespace:WaveDude.WPF.Controls"
+ xmlns:localization="clr-namespace:WaveDude.WPF.Localization">
<!-- editors used by the property views: VS look, colours from the theme table -->
@@ -313,7 +314,15 @@
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
- <TextBlock Text="{Binding Converter={StaticResource EnumName}}" />
+ <!-- the language is a second input, so the words follow a switch -->
+ <TextBlock>
+ <TextBlock.Text>
+ <MultiBinding Converter="{StaticResource EnumName}">
+ <Binding />
+ <Binding Path="Current" Source="{x:Static localization:LanguageController.Instance}" />
+ </MultiBinding>
+ </TextBlock.Text>
+ </TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>