添加项目文件。
This commit is contained in:
281
QuickModeling/Views/ConfigurationView.xaml
Normal file
281
QuickModeling/Views/ConfigurationView.xaml
Normal file
@@ -0,0 +1,281 @@
|
||||
<Window x:Class="QuickModeling.Views.ConfigurationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:conv="clr-namespace:QuickModeling.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:QuickModeling.Models"
|
||||
xmlns:markup="clr-namespace:QuickModeling.Markup"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="clr-namespace:QuickModeling.Models"
|
||||
xmlns:vm="clr-namespace:QuickModeling.ViewModels"
|
||||
Width="640"
|
||||
Height="450"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=vm:ConfigurationViewModel}"
|
||||
Title="{Binding Config.Name}"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Window.Resources>
|
||||
<conv:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
|
||||
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type GroupItem}">
|
||||
<Expander IsExpanded="True">
|
||||
<Expander.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontWeight="Bold" Text="参数分组:" />
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Name}" />
|
||||
<TextBlock Text="{Binding ItemCount, StringFormat=' (合计数量 = \{0} )'}" />
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<ItemsPresenter />
|
||||
</Expander>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="Padding" Value="4" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<Style TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<Style TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<TextBlock Text="所属构件类型:" />
|
||||
<ComboBox Width="100"
|
||||
ItemsSource="{markup:EnumSource EnumType=local:ComponentType, BindToDescription=True}"
|
||||
SelectedValue="{Binding Config.ComponentType}" />
|
||||
<TextBlock Text="配置名称:" />
|
||||
<TextBox Width="100"
|
||||
Text="{Binding Config.Name, UpdateSourceTrigger=PropertyChanged}"
|
||||
ToolTip="配置名称对应ItemTypes名称" />
|
||||
<TextBlock Text="配置备注:" />
|
||||
<TextBox Width="100" Text="{Binding Config.Description, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
</StackPanel>
|
||||
<GroupBox Grid.Row="1"
|
||||
Margin="5"
|
||||
Header="添加参数">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Text="参数分组:" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Width="100"
|
||||
ItemsSource="{Binding Groups}"
|
||||
SelectedItem="{Binding Parameter.Group, Mode=TwoWay}"
|
||||
ToolTip="参数分组对应ItemType" />
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Text="分组名称:" />
|
||||
<TextBox Grid.Row="0"
|
||||
Grid.Column="3"
|
||||
Width="100"
|
||||
Text="{Binding GroupName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="4"
|
||||
Command="{Binding AddGroupCommand}"
|
||||
Content="添加分组"
|
||||
ToolTip="将填写的分组名称添加到可选的分组中" />
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Text="参数名称:" />
|
||||
<TextBox Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Width="100"
|
||||
Text="{Binding Parameter.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Text="数据类型:" />
|
||||
<ComboBox Grid.Row="1"
|
||||
Grid.Column="3"
|
||||
Width="100"
|
||||
ItemsSource="{markup:EnumSource EnumType={x:Type model:TypeKind}, BindToDescription=True}"
|
||||
SelectedValue="{Binding Parameter.DataType}" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="4"
|
||||
HorizontalAlignment="Right"
|
||||
Text="参数值:" />
|
||||
<TextBox Grid.Row="1"
|
||||
Grid.Column="5"
|
||||
Width="100"
|
||||
Text="{Binding Parameter.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<!-- <TextBlock Text="单位:" />
|
||||
<ComboBox Width="100" ItemsSource="{markup:EnumSource EnumType={x:Type model:WorkingUnit}, BindToDescription=True}"/> -->
|
||||
<Button Grid.Row="1"
|
||||
Grid.Column="6"
|
||||
Command="{Binding AddParameterCommand}"
|
||||
Content="添加参数" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="2"
|
||||
Margin="5"
|
||||
Header="参数列表">
|
||||
<DataGrid AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
ItemsSource="{Binding Config.Parameters}"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsVirtualizingWhenGrouping="True">
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridCell">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<ContentPresenter VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<!-- <Style.Triggers>
|
||||
<Trigger Property="Validation.HasError" Value="true">
|
||||
<Setter Property="Background" Value="Pink" />
|
||||
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />
|
||||
</Trigger>
|
||||
</Style.Triggers> -->
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
<DataGrid.RowValidationErrorTemplate>
|
||||
<ControlTemplate>
|
||||
<Grid ToolTip="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}, Path=(Validation.Errors).CurrentItem.ErrorContent}">
|
||||
<!-- <Ellipse Width="{TemplateBinding FontSize}"
|
||||
Height="{TemplateBinding FontSize}"
|
||||
Fill="Red"
|
||||
StrokeThickness="0" /> -->
|
||||
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
FontWeight="Bold"
|
||||
Foreground="Red"
|
||||
Text="!" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</DataGrid.RowValidationErrorTemplate>
|
||||
<DataGrid.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
|
||||
<GroupStyle.Panel>
|
||||
<ItemsPanelTemplate>
|
||||
<DataGridRowsPresenter />
|
||||
</ItemsPanelTemplate>
|
||||
</GroupStyle.Panel>
|
||||
</GroupStyle>
|
||||
</DataGrid.GroupStyle>
|
||||
<DataGrid.Columns>
|
||||
<!-- <DataGridTextColumn Width="Auto"
|
||||
Binding="{Binding Group}"
|
||||
Header="分组" /> -->
|
||||
<DataGridTemplateColumn Width="Auto" Header="参数分组">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Width="100" Text="{Binding Group}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox Width="100"
|
||||
ItemsSource="{Binding DataContext.Groups, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||
SelectedItem="{Binding Group, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Width="2*"
|
||||
Binding="{Binding Name,
|
||||
ValidatesOnNotifyDataErrors=True,
|
||||
UpdateSourceTrigger=PropertyChanged}"
|
||||
Header="参数名称" />
|
||||
<DataGridTextColumn Width="*"
|
||||
Binding="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
Header="参数值" />
|
||||
<!-- <DataGridTextColumn Width="Auto"
|
||||
Binding="{Binding DataType, Converter={StaticResource EnumToDescriptionConverter}}"
|
||||
Header="数据类型" /> -->
|
||||
<DataGridTemplateColumn Header="值类型">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Width="100" Text="{Binding DataType, Converter={StaticResource EnumToDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox Width="100"
|
||||
ItemsSource="{markup:EnumSource EnumType={x:Type model:TypeKind}, BindToDescription=True}"
|
||||
SelectedValue="{Binding DataType, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<!-- <DataGridTextColumn Width="Auto"
|
||||
Binding="{Binding Unit}"
|
||||
Header="单位" /> -->
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button Margin="2"
|
||||
Command="{Binding DataContext.DeleteParameterCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="删除"
|
||||
ToolTip="删除参数" />
|
||||
<!-- <StackPanel Orientation="Horizontal">
|
||||
<Button Margin="2"
|
||||
Command="{Binding DataContext.EditParameterCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="编辑" />
|
||||
|
||||
</StackPanel> -->
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</GroupBox>
|
||||
<UniformGrid Grid.Row="3"
|
||||
HorizontalAlignment="Right"
|
||||
Rows="1">
|
||||
<Button Command="{Binding SendConfigCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
Content="确定" />
|
||||
<Button Command="{Binding CloseWindowCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
Content="取消" />
|
||||
</UniformGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user