161 lines
8.0 KiB
XML
161 lines
8.0 KiB
XML
<Window x:Class="MembranePoreTester.Views.ValveControlWindow"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:local="clr-namespace:MembranePoreTester.Converters"
|
|
Title="阀门控制" Width="1024" Height="768"
|
|
WindowStartupLocation="CenterOwner" WindowState="Maximized"
|
|
Background="#F5F7FA" FontFamily="Segoe UI">
|
|
<Window.Resources>
|
|
<local:BoolToStringConverter x:Key="BoolToStringConverter"/>
|
|
|
|
<!-- 统一按钮样式 -->
|
|
<Style TargetType="Button">
|
|
<Setter Property="Background" Value="#2196F3"/>
|
|
<Setter Property="Foreground" Value="White"/>
|
|
<Setter Property="BorderThickness" Value="0"/>
|
|
<Setter Property="Padding" Value="12,6"/>
|
|
<Setter Property="Margin" Value="5"/>
|
|
<Setter Property="FontSize" Value="12"/>
|
|
<Setter Property="Cursor" Value="Hand"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="Button">
|
|
<Border Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
</Border>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
<Style.Triggers>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter Property="Background" Value="#1976D2"/>
|
|
</Trigger>
|
|
<Trigger Property="IsPressed" Value="True">
|
|
<Setter Property="Background" Value="#0D47A1"/>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
|
|
<!-- 统一组合框样式 -->
|
|
<Style TargetType="ComboBox">
|
|
<Setter Property="Height" Value="28"/>
|
|
<Setter Property="Margin" Value="5"/>
|
|
<Setter Property="FontSize" Value="12"/>
|
|
<Setter Property="Background" Value="White"/>
|
|
<Setter Property="BorderBrush" Value="#D0D3D9"/>
|
|
<Setter Property="BorderThickness" Value="1"/>
|
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
</Style>
|
|
|
|
<!-- 统一文本框样式 -->
|
|
<Style TargetType="TextBox">
|
|
<Setter Property="Height" Value="28"/>
|
|
<Setter Property="Margin" Value="5"/>
|
|
<Setter Property="FontSize" Value="12"/>
|
|
<Setter Property="Background" Value="White"/>
|
|
<Setter Property="BorderBrush" Value="#D0D3D9"/>
|
|
<Setter Property="BorderThickness" Value="1"/>
|
|
<Setter Property="Padding" Value="5,2"/>
|
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
</Style>
|
|
|
|
<!-- 统一标签样式 -->
|
|
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
|
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
<Setter Property="FontSize" Value="12"/>
|
|
<Setter Property="Foreground" Value="#2C3E50"/>
|
|
</Style>
|
|
|
|
<!-- ToggleButton 样式(开关按钮) -->
|
|
<Style TargetType="ToggleButton">
|
|
<Setter Property="Background" Value="#9E9E9E"/>
|
|
<Setter Property="Foreground" Value="White"/>
|
|
<Setter Property="BorderThickness" Value="0"/>
|
|
<Setter Property="Padding" Value="8,4"/>
|
|
<Setter Property="Margin" Value="5"/>
|
|
<Setter Property="FontSize" Value="12"/>
|
|
<Setter Property="Cursor" Value="Hand"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="ToggleButton">
|
|
<Border Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
</Border>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
<Style.Triggers>
|
|
<Trigger Property="IsChecked" Value="True">
|
|
<Setter Property="Background" Value="#4CAF50"/>
|
|
</Trigger>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter Property="Background" Value="#757575"/>
|
|
</Trigger>
|
|
<Trigger Property="IsChecked" Value="True">
|
|
<Setter Property="Background" Value="#45a049"/>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
|
|
<!-- ItemsControl 项容器样式(圆角边框,交替背景) -->
|
|
<Style TargetType="ContentPresenter">
|
|
<Setter Property="Margin" Value="0,2"/>
|
|
</Style>
|
|
<Style TargetType="Border" x:Key="ValveItemBorder">
|
|
<Setter Property="Background" Value="White"/>
|
|
<Setter Property="CornerRadius" Value="4"/>
|
|
<Setter Property="BorderBrush" Value="#E9ECF0"/>
|
|
<Setter Property="BorderThickness" Value="1"/>
|
|
<Setter Property="Padding" Value="10,8"/>
|
|
<Setter Property="Margin" Value="0,2"/>
|
|
</Style>
|
|
</Window.Resources>
|
|
|
|
<Grid Margin="10">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- 工位选择卡片 -->
|
|
<Border Grid.Row="0" Background="White" CornerRadius="6" Padding="10" Margin="0,0,0,10" BorderBrush="#E9ECF0" BorderThickness="1">
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Text="工位:" VerticalAlignment="Center" Margin="5"/>
|
|
<ComboBox x:Name="cmbStation" Width="80" SelectionChanged="CmbStation_SelectionChanged">
|
|
<ComboBoxItem IsSelected="True" Content="工位1"/>
|
|
<ComboBoxItem Content="工位2"/>
|
|
<ComboBoxItem Content="工位3"/>
|
|
</ComboBox>
|
|
<Button Content="🔄 刷新状态" Click="Refresh_Click" Margin="10,0,0,0" Background="#607D8B"/>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- 阀门列表(带滚动条,整体卡片) -->
|
|
<Border Grid.Row="1" Background="White" CornerRadius="6" BorderBrush="#E9ECF0" BorderThickness="1" Padding="5">
|
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
|
<ItemsControl x:Name="valveList">
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<Border Style="{StaticResource ValveItemBorder}">
|
|
<Grid>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="150"/>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="80"/>
|
|
</Grid.ColumnDefinitions>
|
|
<TextBlock Text="{Binding Name}" FontWeight="SemiBold" VerticalAlignment="Center"/>
|
|
<TextBlock Grid.Column="1" Text="{Binding CoilAddress}" Foreground="#7F8C8D" VerticalAlignment="Center" FontSize="11"/>
|
|
<ToggleButton Grid.Column="2" IsChecked="{Binding IsOn, Mode=TwoWay}"
|
|
Checked="ToggleButton_Checked"
|
|
Unchecked="ToggleButton_Unchecked"
|
|
Content="{Binding IsOn, Converter={StaticResource BoolToStringConverter}}"
|
|
HorizontalAlignment="Right" Width="70"/>
|
|
</Grid>
|
|
</Border>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
</ScrollViewer>
|
|
</Border>
|
|
</Grid>
|
|
</Window> |