mirror of
https://github.com/fadden/6502bench.git
synced 2024-08-16 00:28:56 +00:00
Basic infrastructure for taking a list of parameters from a plugin and turning it into a collection of UI controls, merging in values from a Visualization object. Doesn't yet do anything useful. WPF makes the hard things easy and the easy things hard. This was a hard thing, so it was easy to do (with some helpful sample code). Yay WPF?
121 lines
5.3 KiB
XML
121 lines
5.3 KiB
XML
<!--
|
|
Copyright 2019 faddenSoft
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<Window x:Class="SourceGen.WpfGui.EditVisualization"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
|
xmlns:local="clr-namespace:SourceGen.WpfGui"
|
|
mc:Ignorable="d"
|
|
Title="Edit Visualization"
|
|
Width="460" SizeToContent="Height" ResizeMode="NoResize"
|
|
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
|
|
Loaded="Window_Loaded">
|
|
|
|
<Window.Resources>
|
|
<!-- big thanks: http://drwpf.com/blog/2008/01/03/itemscontrol-d-is-for-datatemplate/ -->
|
|
<DataTemplate x:Key="BoolTemplate">
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Width="100" Text="{Binding UiName}"/>
|
|
<CheckBox IsChecked="{Binding Value}"/>
|
|
<TextBlock Text="{Binding RangeText}" FontFamily="{StaticResource GeneralMonoFont}"/>
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
<DataTemplate x:Key="IntTemplate">
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Width="100" Text="{Binding UiName}"/>
|
|
<TextBox Width="100" MaxLength="11" Text="{Binding Value}"
|
|
FontFamily="{StaticResource GeneralMonoFont}"
|
|
TextChanged="TextBox_TextChanged"/>
|
|
<TextBlock Text="{Binding RangeText}" FontFamily="{StaticResource GeneralMonoFont}"/>
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
<DataTemplate x:Key="FloatTemplate">
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Width="100" Text="{Binding UiName}"/>
|
|
<TextBox Width="100" MaxLength="11" Text="{Binding Value}"
|
|
FontFamily="{StaticResource GeneralMonoFont}"
|
|
TextChanged="TextBox_TextChanged"/>
|
|
<TextBlock Text="{Binding RangeText}" FontFamily="{StaticResource GeneralMonoFont}"/>
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
|
|
<!-- define and configure the template selector, which chooses one of the above
|
|
templates based on the parameter data type -->
|
|
<local:ParameterTemplateSelector x:Key="ParameterTemplateSelector"
|
|
BoolTemplate="{StaticResource BoolTemplate}"
|
|
IntTemplate="{StaticResource IntTemplate}"
|
|
FloatTemplate="{StaticResource FloatTemplate}"/>
|
|
</Window.Resources>
|
|
|
|
<Grid Margin="8">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<Grid Grid.Row="0">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Margin="0,0,4,0"
|
|
Text="Visualizer:"/>
|
|
<ComboBox Grid.Column="1" Grid.Row="0" />
|
|
|
|
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="0,0,4,0"
|
|
Text="Tag:"/>
|
|
<TextBox Grid.Column="1" Grid.Row="1" Width="300"
|
|
Text="{Binding TagString, UpdateSourceTrigger=PropertyChanged}"/>
|
|
|
|
<TextBlock Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Text="Preview:"/>
|
|
</Grid>
|
|
|
|
<Image Grid.Row="1" Width="50" Height="50"/>
|
|
|
|
<Grid Grid.Row="2">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<TextBlock Grid.Row="0" Text="Parameters:"/>
|
|
|
|
<!-- generated controls are placed here -->
|
|
<ItemsControl Grid.Row="1"
|
|
ItemsSource="{Binding ParameterList}"
|
|
ItemTemplateSelector="{StaticResource ParameterTemplateSelector}">
|
|
</ItemsControl>
|
|
</Grid>
|
|
|
|
<DockPanel Grid.Column="0" Grid.Row="3" Margin="0,8,0,0" LastChildFill="False">
|
|
<Button DockPanel.Dock="Right" Content="Cancel" Width="70" Margin="8,0,0,0" IsCancel="True"/>
|
|
<Button DockPanel.Dock="Right" Grid.Column="1" Content="OK" Width="70"
|
|
IsDefault="True" Click="OkButton_Click"/>
|
|
</DockPanel>
|
|
</Grid>
|
|
</Window>
|