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#
3.5 KB
Raw Blame
<!--
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2026 Alexander Graef <[email protected]>

This file is part of WaveDude Next, a 2D wave simulator.

Based on the work of
  Jeroen Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
    <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
  0x23 (Diffraction Limited), author of WaveSimulator2D
    <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>

WaveDude Next is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<https://www.gnu.org/licenses/>.
-->

<UserControl x:Class="WaveDudeNext.WPF.Views.PartPointsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:WaveDudeNext.WPF.Controls"
             xmlns:commands="clr-namespace:WaveDudeNext.WPF.Commands"
             xmlns:meta="clr-namespace:WaveDudeNext.WPF.Markup"
             xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">

	<UserControl.CommandBindings>
		<CommandBinding Command="{x:Static commands:PartCommands.AddPoint}" CanExecute="CanAddPoint" Executed="OnAddPoint" />
		<CommandBinding Command="{x:Static commands:PartCommands.RemovePoint}" CanExecute="CanRemovePoint" Executed="OnRemovePoint" />
	</UserControl.CommandBindings>

	<!-- the point list of a polygon outline (the data context is the part): one row per point with X
	     and Y relative to the centre, before rotation, a remove button, and an add button below -->
	<StackPanel>
		<Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionPoints}" />
		<TextBlock Margin="0,0,0,4" Foreground="{DynamicResource GrayText}" TextWrapping="Wrap" Text="{Binding HintText, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
		<DockPanel Margin="0,0,0,2">
			<Border DockPanel.Dock="Right" Width="22" />
			<UniformGrid Columns="2">
				<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:PartPoint.X}" Margin="2,0" />
				<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:PartPoint.Y}" Margin="2,0" />
			</UniformGrid>
		</DockPanel>
		<ItemsControl x:Name="list" ItemsSource="{Binding Points}" Focusable="False">
			<ItemsControl.ItemTemplate>
				<DataTemplate>
					<DockPanel Margin="0,0,0,4">
						<Button DockPanel.Dock="Right" Style="{StaticResource RemovePointButton}" ToolTip="{DynamicResource TipRemovePoint}" AutomationProperties.Name="{DynamicResource TipRemovePoint}"
						        Command="{x:Static commands:PartCommands.RemovePoint}" CommandParameter="{Binding}" />
						<UniformGrid Columns="2">
							<controls:NumberBox Margin="0,0,2,0" Text="{Binding X}" ToolTip="{DynamicResource Hint.PartPoint.X}" />
							<controls:NumberBox Margin="2,0,0,0" Text="{Binding Y}" ToolTip="{DynamicResource Hint.PartPoint.Y}" />
						</UniformGrid>
					</DockPanel>
				</DataTemplate>
			</ItemsControl.ItemTemplate>
		</ItemsControl>
		<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
			<Button Padding="8,2" Margin="0,2,6,0" Content="{DynamicResource ButtonAddPoint}" ToolTip="{DynamicResource TipAddPoint}"
			        Command="{x:Static commands:PartCommands.AddPoint}" AutomationProperties.AutomationId="PartAddPoint" />
		</StackPanel>
	</StackPanel>
</UserControl>