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#

The XAML designer shows the dock panes in the app's first-start arrangement

Alexander Graef5d00dcdcfe0c
diff --git a/CLAUDE.md b/CLAUDE.md
index bd8b4ab..336b02b 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -49,6 +49,10 @@ harnesses run.
dnSpy look (its sources are GPL: look, do not copy). Inside a `DataTemplate` reference the string keys directly
(`{DynamicResource Hint.Type.Member}`): the `meta:Label`/`meta:Hint` extensions wrap a resource reference a template
rejects for a string property and shows as text for an object one (2026-10-22, found on the fibre's node rows). An
+ The XAML designer never runs a window's constructor: what the preview must show lives in XAML, as the dock host's
+ default arrangement does (`DockHost.DefaultLayout` in `MainWindow.xaml`, the one source for the first start and the
+ designer, which then shows every hidden pane at its default side, Messages at the bottom, 2026-10-26; nested types
+ cannot be XML names, so the layout nodes are top-level classes). An
implicit style never reaches a class derived from `Window`, so every window names the theme's
(`Style="{StaticResource {x:Type Window}}"`, 2026-10-23: without its layout rounding the pictures sat at fractional
pixels and WPF resampled them; its Display text formatting had never applied either).
diff --git a/WaveDudeNext.WPF/Docking/DockHost.cs b/WaveDudeNext.WPF/Docking/DockHost.cs
index e507749..b75db86 100644
--- a/WaveDudeNext.WPF/Docking/DockHost.cs
+++ b/WaveDudeNext.WPF/Docking/DockHost.cs
@@ -15,6 +15,7 @@
// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
// <https://www.gnu.org/licenses/>.
+using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -88,6 +89,39 @@ public sealed class DockHost : Grid
});
AddHandler(PreviewMouseDownEvent, new MouseButtonEventHandler(OnPreviewMouseDown), true);
AddHandler(PreviewGotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnPreviewGotKeyboardFocus), true);
+ Loaded += OnLoaded;
+ Rebuild();
+ }
+
+ /// <summary>
+ /// The arrangement of a first start, set in the window's XAML; the window loads it when no saved layout applies, and
+ /// the XAML designer shows it (2026-10-26, the user's request: the designer never runs the window's constructor, so
+ /// its preview had shown the document area alone, and the items docked one by one at their default sides looked
+ /// nothing like the app). Null leaves the host empty until the window shows the items.
+ /// </summary>
+ public DockLayout? DefaultLayout { get; set; }
+
+ /// <summary>
+ /// In the XAML designer, loads <see cref="DefaultLayout"/>, then shows every item it leaves hidden at its default side
+ /// (the user's choice, 2026-10-26: the designer shows every pane, Messages at the bottom, where the app's first start
+ /// hides it). At run time nothing happens here.
+ /// </summary>
+ private void OnLoaded(object sender, RoutedEventArgs e)
+ {
+ if (!DesignerProperties.GetIsInDesignMode(this))
+ {
+ return;
+ }
+ if (DefaultLayout != null)
+ {
+ LoadLayout(DefaultLayout);
+ }
+ // from the model alone, never through Show: that captures the sizes of a visual tree the designer has arranged at
+ // some provisional size, and the left column came out squashed (2026-10-26)
+ foreach (DockItem item in Items.Where(item => item.Group == null).ToList())
+ {
+ InsertRelative(NewGroup(item), _root, item.DefaultSide, EdgeShare);
+ }
Rebuild();
}
@@ -529,29 +563,29 @@ public sealed class DockHost : Grid
// ---- persistence ----
- private DockLayout.NodeLayout Export(DockNode node) => node switch
+ private NodeLayout Export(DockNode node) => node switch
{
- DockSplitNode split => new DockLayout.SplitLayout
+ DockSplitNode split => new SplitLayout
{
Length = split.Length,
Orientation = split.Orientation,
Children = split.Children.Select(Export).ToList(),
},
- DockGroup group => new DockLayout.GroupLayout
+ DockGroup group => new GroupLayout
{
Length = group.Length,
Active = group.ActiveItem?.Id,
Items = group.Items.Select(i => i.Id).ToList(),
},
- _ => new DockLayout.DocumentLayout { Length = node.Length },
+ _ => new DocumentLayout { Length = node.Length },
};
- private DockNode? Import(DockLayout.NodeLayout layout, HashSet<DockItem> assigned)
+ private DockNode? Import(NodeLayout layout, HashSet<DockItem> assigned)
{
double length = layout.Length > 0 ? layout.Length : 1;
switch (layout)
{
- case DockLayout.DocumentLayout:
+ case DocumentLayout:
if (!assigned.Add(DocumentMarker))
{
return null; // a second document node is not allowed
@@ -559,7 +593,7 @@ public sealed class DockHost : Grid
_document.Length = length;
return _document;
- case DockLayout.GroupLayout groupLayout:
+ case GroupLayout groupLayout:
{
var group = new DockGroup { Length = length };
foreach (string id in groupLayout.Items)
@@ -580,10 +614,10 @@ public sealed class DockHost : Grid
return group;
}
- case DockLayout.SplitLayout splitLayout:
+ case SplitLayout splitLayout:
{
var split = new DockSplitNode(splitLayout.Orientation) { Length = length };
- foreach (DockLayout.NodeLayout childLayout in splitLayout.Children)
+ foreach (NodeLayout childLayout in splitLayout.Children)
{
DockNode? child = Import(childLayout, assigned);
if (child != null)
diff --git a/WaveDudeNext.WPF/Docking/DockLayout.cs b/WaveDudeNext.WPF/Docking/DockLayout.cs
index b67fd49..b56485a 100644
--- a/WaveDudeNext.WPF/Docking/DockLayout.cs
+++ b/WaveDudeNext.WPF/Docking/DockLayout.cs
@@ -17,6 +17,7 @@
using System.IO;
using System.Windows.Controls;
+using System.Windows.Markup;
using System.Xml;
using System.Xml.Serialization;
using NLog;
@@ -26,7 +27,8 @@ namespace WaveDudeNext.WPF.Docking;
/// <summary>
/// Serializable snapshot of a <see cref="DockHost"/> layout tree. Items are referenced by
/// <see cref="DockItem.Id"/>; unknown ids are ignored on load. Persisted with
-/// <see cref="XmlSerializer"/>.
+/// <see cref="XmlSerializer"/>; a host's default arrangement is written in XAML (the node classes are top-level, as an XML
+/// name cannot hold a nested type's "+"; children and item ids are content, 2026-10-26).
/// </summary>
[XmlRoot("DockLayout")]
public sealed class DockLayout
@@ -71,34 +73,40 @@ public sealed class DockLayout
return null;
}
}
+}
- public abstract class NodeLayout
- {
- [XmlAttribute]
- public double Length { get; set; } = 1.0;
- }
+/// <summary>A node of a <see cref="DockLayout"/>: a split, a group or the document area; <see cref="Length"/> is its share in the parent split.</summary>
+public abstract class NodeLayout
+{
+ [XmlAttribute]
+ public double Length { get; set; } = 1.0;
+}
- public sealed class SplitLayout : NodeLayout
- {
- [XmlAttribute]
- public Orientation Orientation { get; set; }
+/// <summary>A split of a <see cref="DockLayout"/>, its children in content order.</summary>
+[ContentProperty(nameof(Children))]
+public sealed class SplitLayout : NodeLayout
+{
+ [XmlAttribute]
+ public Orientation Orientation { get; set; }
- [XmlElement("Split", typeof(SplitLayout))]
- [XmlElement("Group", typeof(GroupLayout))]
- [XmlElement("Document", typeof(DocumentLayout))]
- public List<NodeLayout> Children { get; set; } = new();
- }
+ [XmlElement("Split", typeof(SplitLayout))]
+ [XmlElement("Group", typeof(GroupLayout))]
+ [XmlElement("Document", typeof(DocumentLayout))]
+ public List<NodeLayout> Children { get; set; } = new();
+}
- public sealed class GroupLayout : NodeLayout
- {
- [XmlAttribute]
- public string? Active { get; set; }
+/// <summary>A tabbed group of a <see cref="DockLayout"/>: the item ids as content, the active one named.</summary>
+[ContentProperty(nameof(Items))]
+public sealed class GroupLayout : NodeLayout
+{
+ [XmlAttribute]
+ public string? Active { get; set; }
- [XmlElement("Item")]
- public List<string> Items { get; set; } = new();
- }
+ [XmlElement("Item")]
+ public List<string> Items { get; set; } = new();
+}
- public sealed class DocumentLayout : NodeLayout
- {
- }
+/// <summary>The document area of a <see cref="DockLayout"/>.</summary>
+public sealed class DocumentLayout : NodeLayout
+{
}
diff --git a/WaveDudeNext.WPF/MainWindow.xaml b/WaveDudeNext.WPF/MainWindow.xaml
index ce522dd..f3d9383 100644
--- a/WaveDudeNext.WPF/MainWindow.xaml
+++ b/WaveDudeNext.WPF/MainWindow.xaml
@@ -23,6 +23,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
xmlns:local="clr-namespace:WaveDudeNext.WPF"
xmlns:controls="clr-namespace:WaveDudeNext.WPF.Controls"
xmlns:docking="clr-namespace:WaveDudeNext.WPF.Docking"
+ xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:theming="clr-namespace:WaveDudeNext.WPF.Theming"
xmlns:localization="clr-namespace:WaveDudeNext.WPF.Localization"
xmlns:converters="clr-namespace:WaveDudeNext.WPF.Converters"
@@ -390,6 +391,22 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
</StatusBar>
<docking:DockHost x:Name="dockHost">
+ <!-- the arrangement of a first start (agreed 2026-10-09): a left column of a quarter of the width with the Project
+ tree in its upper third and the Properties pane below it, the preview in the rest; Messages hidden. Loaded by
+ the window when no saved layout applies, and by the designer (2026-10-26) -->
+ <docking:DockHost.DefaultLayout>
+ <docking:DockLayout>
+ <docking:DockLayout.Root>
+ <docking:SplitLayout Orientation="Horizontal">
+ <docking:SplitLayout Orientation="Vertical" Length="1">
+ <docking:GroupLayout Active="project" Length="1"><s:String>project</s:String></docking:GroupLayout>
+ <docking:GroupLayout Active="properties" Length="2"><s:String>properties</s:String></docking:GroupLayout>
+ </docking:SplitLayout>
+ <docking:DocumentLayout Length="3" />
+ </docking:SplitLayout>
+ </docking:DockLayout.Root>
+ </docking:DockLayout>
+ </docking:DockHost.DefaultLayout>
<docking:DockHost.Items>
<docking:DockItem x:Name="projectDock" Id="project" Title="{StaticResource PaneProject}" DefaultSide="Left">
<panes:ProjectTree x:Name="projectTree" Project="{Binding Project}" SelectedItems="{Binding SelectedItems}" SelectedItemChanged="OnTreeSelectionChanged" />
diff --git a/WaveDudeNext.WPF/MainWindow.xaml.cs b/WaveDudeNext.WPF/MainWindow.xaml.cs
index 5760fb6..3e10306 100644
--- a/WaveDudeNext.WPF/MainWindow.xaml.cs
+++ b/WaveDudeNext.WPF/MainWindow.xaml.cs
@@ -75,7 +75,7 @@ public partial class MainWindow : Window
Project = new Project();
InitializeComponent();
- if (!TryLoadLayout() && !dockHost.LoadLayout(DefaultLayout()))
+ if (!TryLoadLayout() && (dockHost.DefaultLayout == null || !dockHost.LoadLayout(dockHost.DefaultLayout)))
{
// Messages stays hidden until asked for (View > Panes, status bar double-click)
dockHost.Show(projectDock);
@@ -582,32 +582,6 @@ public partial class MainWindow : Window
}
}
- /// <summary>
- /// The arrangement of a first start (agreed 2026-10-09): a left column of a quarter of the width with the
- /// Project tree in its upper third and the Properties pane below it, the preview in the rest; Messages hidden.
- /// </summary>
- private DockLayout DefaultLayout() => new()
- {
- Root = new DockLayout.SplitLayout
- {
- Orientation = Orientation.Horizontal,
- Children =
- {
- new DockLayout.SplitLayout
- {
- Orientation = Orientation.Vertical,
- Length = 1,
- Children =
- {
- new DockLayout.GroupLayout { Items = { projectDock.Id }, Active = projectDock.Id, Length = 1 },
- new DockLayout.GroupLayout { Items = { propertiesDock.Id }, Active = propertiesDock.Id, Length = 2 },
- },
- },
- new DockLayout.DocumentLayout { Length = 3 },
- },
- },
- };
-
private bool TryLoadLayout()
{
DockLayout? layout = Settings.Default.Layout;