163 lines
8.9 KiB
Plaintext
163 lines
8.9 KiB
Plaintext
|
|
<Window x:Class="QuickModeling.Views.ConfigurationsManagerView"
|
|||
|
|
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"
|
|||
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|||
|
|
xmlns:vm="clr-namespace:QuickModeling.ViewModels"
|
|||
|
|
Width="450"
|
|||
|
|
Height="500"
|
|||
|
|
mc:Ignorable="d"
|
|||
|
|
WindowStartupLocation="CenterOwner"
|
|||
|
|
d:DataContext="{d:DesignInstance Type=vm:ConfigurationManagerViewModel}"
|
|||
|
|
Title="配置管理">
|
|||
|
|
<Window.Resources>
|
|||
|
|
<!-- <Style TargetType="DataGridCell">
|
|||
|
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
|||
|
|
<Setter Property="Template">
|
|||
|
|
<Setter.Value>
|
|||
|
|
<ControlTemplate TargetType="DataGridCell">
|
|||
|
|
<Grid Background="{TemplateBinding Background}">
|
|||
|
|
<ContentPresenter VerticalAlignment="Center"/>
|
|||
|
|
</Grid>
|
|||
|
|
</ControlTemplate>
|
|||
|
|
</Setter.Value>
|
|||
|
|
</Setter>
|
|||
|
|
</Style> -->
|
|||
|
|
<conv:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
|
|||
|
|
<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>
|
|||
|
|
<UniformGrid Rows="1">
|
|||
|
|
<Button Margin="5"
|
|||
|
|
Command="{Binding AddConfigCommand}"
|
|||
|
|
CommandParameter="{Binding ElementName=ConfigsDataGrid,
|
|||
|
|
Path=SelectedItem,
|
|||
|
|
UpdateSourceTrigger=PropertyChanged}"
|
|||
|
|
Content="新建配置"
|
|||
|
|
ToolTip="新建一个配置" />
|
|||
|
|
<Button Margin="5"
|
|||
|
|
Command="{Binding ImportConfigsCommand}"
|
|||
|
|
CommandParameter="{Binding ElementName=ConfigsDataGrid, Path=ItemsSource}"
|
|||
|
|
Content="导入配置表"
|
|||
|
|
ToolTip="会附加所选文件的配置到当前配置,相同的Guid的配置会覆盖" />
|
|||
|
|
<Button Margin="5"
|
|||
|
|
Command="{Binding ExportConfigsCommand}"
|
|||
|
|
CommandParameter="{Binding ElementName=ConfigsDataGrid, Path=ItemsSource}"
|
|||
|
|
Content="导出配置表"
|
|||
|
|
ToolTip="导出当前的所有配置" />
|
|||
|
|
</UniformGrid>
|
|||
|
|
<GroupBox Grid.Row="2"
|
|||
|
|
Margin="5"
|
|||
|
|
Header="配置列表">
|
|||
|
|
<DataGrid x:Name="ConfigsDataGrid"
|
|||
|
|
CanUserDeleteRows="False"
|
|||
|
|
AutoGenerateColumns="False"
|
|||
|
|
CanUserAddRows="False"
|
|||
|
|
d:ItemsSource="{d:SampleData ItemCount=5}"
|
|||
|
|
GridLinesVisibility="All"
|
|||
|
|
ItemsSource="{Binding Configs}"
|
|||
|
|
SelectionMode="Single"
|
|||
|
|
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" />
|
|||
|
|
<!-- 确保 TextBlock 也垂直居中(如果列内容是 TextBlock) -->
|
|||
|
|
</Style>
|
|||
|
|
</DataGrid.CellStyle>
|
|||
|
|
<DataGrid.Columns>
|
|||
|
|
<DataGridCheckBoxColumn Width="Auto"
|
|||
|
|
Binding="{Binding IsEnabled, UpdateSourceTrigger=PropertyChanged}">
|
|||
|
|
<DataGridCheckBoxColumn.Header>
|
|||
|
|
<CheckBox Content="启用"
|
|||
|
|
IsThreeState="False"
|
|||
|
|
VerticalAlignment="Center"
|
|||
|
|
HorizontalAlignment="Center"
|
|||
|
|
IsChecked="{Binding DataContext.AreAllEnabled, Mode=TwoWay,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid},UpdateSourceTrigger=PropertyChanged}" />
|
|||
|
|
</DataGridCheckBoxColumn.Header>
|
|||
|
|
</DataGridCheckBoxColumn>
|
|||
|
|
|
|||
|
|
<DataGridTextColumn Width="Auto"
|
|||
|
|
Binding="{Binding Name, Mode=TwoWay}"
|
|||
|
|
Header="配置名称"
|
|||
|
|
IsReadOnly="True" />
|
|||
|
|
<DataGridTextColumn Width="Auto"
|
|||
|
|
Binding="{Binding ComponentType, Converter={StaticResource EnumToDescriptionConverter}}"
|
|||
|
|
Header="构件类型"
|
|||
|
|
IsReadOnly="True" />
|
|||
|
|
<DataGridTextColumn Width="*"
|
|||
|
|
Binding="{Binding Description}"
|
|||
|
|
Header="描述"
|
|||
|
|
IsReadOnly="True" />
|
|||
|
|
<!-- <DataGridTemplateColumn Width="Auto" Header="预览">
|
|||
|
|
<DataGridTemplateColumn.CellTemplate>
|
|||
|
|
<DataTemplate>
|
|||
|
|
<Image />
|
|||
|
|
</DataTemplate>
|
|||
|
|
</DataGridTemplateColumn.CellTemplate>
|
|||
|
|
</DataGridTemplateColumn> -->
|
|||
|
|
<DataGridTemplateColumn Width="Auto" Header="操作">
|
|||
|
|
<DataGridTemplateColumn.CellTemplate>
|
|||
|
|
<DataTemplate>
|
|||
|
|
<StackPanel Orientation="Horizontal">
|
|||
|
|
<Button Command="{Binding DataContext.EditConfigCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
|||
|
|
CommandParameter="{Binding}"
|
|||
|
|
Content="编辑"
|
|||
|
|
ToolTip="编辑当前配置" />
|
|||
|
|
<Button Command="{Binding DataContext.CopyConfigCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
|||
|
|
CommandParameter="{Binding}"
|
|||
|
|
Content="复制"
|
|||
|
|
ToolTip="复制当前配置" />
|
|||
|
|
<Button Command="{Binding DataContext.RemoveConfigCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
|||
|
|
CommandParameter="{Binding}"
|
|||
|
|
Content="删除"
|
|||
|
|
ToolTip="删除当前配置" />
|
|||
|
|
|
|||
|
|
</StackPanel>
|
|||
|
|
</DataTemplate>
|
|||
|
|
</DataGridTemplateColumn.CellTemplate>
|
|||
|
|
</DataGridTemplateColumn>
|
|||
|
|
</DataGrid.Columns>
|
|||
|
|
</DataGrid>
|
|||
|
|
</GroupBox>
|
|||
|
|
<Button Grid.Row="3"
|
|||
|
|
Margin="5"
|
|||
|
|
Command="{Binding SaveConfigsCommand}"
|
|||
|
|
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
|||
|
|
Content="保存配置表" />
|
|||
|
|
</Grid>
|
|||
|
|
</Window>
|