Files
CapMachine/CapMachine.Shared/Controls/MeterConfig.xaml
2024-09-25 15:44:59 +08:00

322 lines
17 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<UserControl
x:Class="CapMachine.Shared.Controls.MeterConfig"
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:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:CapMachine.Shared.Controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="MeterConfigInstance"
d:DesignHeight="400"
d:DesignWidth="300"
mc:Ignorable="d">
<UserControl.Resources>
<local:BoolNgConvert x:Key="BoolNgConverter" />
<local:SecToStrConvert x:Key="SecToStrConverter" />
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="FontSize" Value="24" />
<Setter Property="Width" Value="218" />
</Style>
<Style x:Key="myHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="FontSize" Value="16" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
<DockPanel Background="White">
<!--<StackPanel DockPanel.Dock="Left" Orientation="Horizontal">
<TextBlock
Margin="15,0,5,0"
VerticalAlignment="Center"
Text="常值/斜率:" />
<ToggleButton
x:Name="TBSwitchConstSlop"
Command="{Binding ElementName=MeterConfigInstance, Path=SwitchConstSlopCommand}"
CommandParameter="{Binding ElementName=TBSwitchConstSlop, Path=IsChecked}"
IsChecked="{Binding ElementName=MeterConfigInstance, Path=SwitchConstSlopPar}"
Style="{StaticResource MaterialDesignSwitchToggleButton}"
ToolTip="常值和斜率选项" />
-->
<!-- IsChecked="{Binding ElementName=MeterConfigInstance, Path=SwitchConstSlopPar}" -->
<!--
</StackPanel>-->
<TextBlock
Margin="0,0,5,0"
VerticalAlignment="Center"
DockPanel.Dock="Right"
FontSize="18"
Foreground="Blue"
Text="{Binding ElementName=MeterConfigInstance, Path=MeterName}"
TextAlignment="Right" />
</DockPanel>
<TabControl
x:Name="MainTabControl"
Grid.Row="1"
SelectedIndex="{Binding ElementName=MeterConfigInstance, Path=ConstSlopSelectedIndex}">
<TabControl.Style>
<Style BasedOn="{StaticResource MaterialDesignFilledTabControl}" TargetType="TabControl">
<!--<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=TBSwitchConstSlop}" Value="True">
<Setter Property="SelectedIndex" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding IsChecked, ElementName=TBSwitchConstSlop}" Value="False">
<Setter Property="SelectedIndex" Value="0" />
</DataTrigger>
</Style.Triggers>-->
</Style>
</TabControl.Style>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ElementName=MeterConfigInstance, Path=SwitchConstSlopCommand}" CommandParameter="{Binding ElementName=MainTabControl, Path=SelectedIndex}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<!-- IsEnabled="{Binding IsChecked, ElementName=TBSwitchConstSlop, Converter={StaticResource BoolNgConverter}}" -->
<TabItem Header="常值">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Margin="10" Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" FontSize="16">常值数据</TextBlock>
<TextBox
Width="200"
HorizontalContentAlignment="Center"
FontSize="20"
Text="{Binding ElementName=MeterConfigInstance, Path=ConstantValue}" />
</StackPanel>
<StackPanel Grid.Row="1" VerticalAlignment="Center">
<Button
Width="80"
Margin="0,0,20,0"
Command="{Binding ElementName=MeterConfigInstance, Path=ConstantSaveCommand}"
Content="确定"
Foreground="White" />
</StackPanel>
</Grid>
</TabItem>
<!-- IsEnabled="{Binding IsChecked, ElementName=TBSwitchConstSlop}" -->
<TabItem Header="斜率">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.8*" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="1.4*" />
</Grid.ColumnDefinitions>
<StackPanel Margin="1,10,0,0">
<TextBox
VerticalAlignment="Top"
materialDesign:HintAssist.Hint="序号"
FontSize="13"
FontWeight="Bold"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
Text="{Binding ElementName=MeterConfigInstance, Path=SelectedMeter.StepNo}"
TextWrapping="NoWrap"
VerticalScrollBarVisibility="Disabled">
<TextBox.ToolTip>
<TextBlock
FontSize="14"
FontWeight="Bold"
Text="新增时自动填充序号;可手动修改序号" />
</TextBox.ToolTip>
</TextBox>
</StackPanel>
<StackPanel Grid.Column="1" Margin="1,10,0,0">
<TextBox
VerticalAlignment="Top"
materialDesign:HintAssist.Hint="起始值"
FontSize="13"
FontWeight="Bold"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
Text="{Binding ElementName=MeterConfigInstance, Path=SelectedMeter.StartValue}"
TextWrapping="NoWrap"
VerticalScrollBarVisibility="Disabled">
<TextBox.ToolTip>
<TextBlock
FontSize="14"
FontWeight="Bold"
Text="起始值" />
</TextBox.ToolTip>
</TextBox>
</StackPanel>
<StackPanel Grid.Column="2" Margin="1,10,0,0">
<TextBox
VerticalAlignment="Top"
materialDesign:HintAssist.Hint="结束值"
FontSize="13"
FontWeight="Bold"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
Text="{Binding ElementName=MeterConfigInstance, Path=SelectedMeter.EndValue}"
TextWrapping="NoWrap"
VerticalScrollBarVisibility="Disabled">
<TextBox.ToolTip>
<TextBlock
FontSize="14"
FontWeight="Bold"
Text="结束值" />
</TextBox.ToolTip>
</TextBox>
</StackPanel>
<StackPanel Grid.Column="3" Margin="1,10,3,0">
<TextBox
VerticalAlignment="Top"
materialDesign:HintAssist.Hint="维持时间"
FontSize="13"
FontWeight="Bold"
IsEnabled="True"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
Text="{Binding ElementName=MeterConfigInstance, Path=SelectedMeter.KeepTime, Converter={StaticResource SecToStrConverter}}"
TextWrapping="NoWrap"
VerticalScrollBarVisibility="Disabled">
<TextBox.ToolTip>
<TextBlock
FontSize="14"
FontWeight="Bold"
Text="维持时间" />
</TextBox.ToolTip>
</TextBox>
</StackPanel>
</Grid>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Button
Margin="2,2"
Background="IndianRed"
Command="{Binding ElementName=MeterConfigInstance, Path=AddCommand}"
Content="增加"
Foreground="White"
Style="{StaticResource MaterialDesignRaisedSecondaryLightButton}"
ToolTip="增加程序步骤内的速度设置" />
<Button
Margin="1,2"
Background="IndianRed"
Command="{Binding ElementName=MeterConfigInstance, Path=EditCommand}"
Content="修改"
Foreground="White"
Style="{StaticResource MaterialDesignRaisedSecondaryLightButton}"
ToolTip="修改程序步骤内的速度设置,请先选中" />
<Button
Margin="1,2"
Background="IndianRed"
Command="{Binding ElementName=MeterConfigInstance, Path=DeleteCommand}"
Content="删除"
Foreground="White"
Style="{StaticResource MaterialDesignRaisedSecondaryLightButton}"
ToolTip="删除程序步骤内的速度设置,请先选中" />
<StackPanel Margin="2,2,2,2" Orientation="Vertical">
<TextBlock
HorizontalAlignment="Center"
Foreground="Blue"
Text="时间" />
<TextBlock
VerticalAlignment="Center"
FontSize="16"
Foreground="Blue"
Text="{Binding ElementName=MeterConfigInstance, Path=TotalSlopTime, Converter={StaticResource SecToStrConverter}}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=MeterConfigInstance, Path=IsTimeOk}" Value="true">
<Setter Property="Background" Value="LimeGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=MeterConfigInstance, Path=IsTimeOk}" Value="false">
<Setter Property="Background" Value="OrangeRed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<StackPanel Margin="1,2,2,2" Orientation="Vertical">
<TextBlock
HorizontalAlignment="Center"
Foreground="Blue"
Text="循环" />
<TextBlock
VerticalAlignment="Center"
FontSize="16"
Foreground="Blue"
Text="{Binding ElementName=MeterConfigInstance, Path=Cycle, StringFormat=0.0}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=MeterConfigInstance, Path=IsTimeOk}" Value="true">
<Setter Property="Background" Value="LimeGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=MeterConfigInstance, Path=IsTimeOk}" Value="false">
<Setter Property="Background" Value="OrangeRed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
</StackPanel>
<Border
Grid.Row="2"
Margin="1,0"
BorderBrush="Black"
BorderThickness="1">
<ListView
x:Name="listviewMeter"
Foreground="Black"
ItemsSource="{Binding ElementName=MeterConfigInstance, Path=ListMeter}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ElementName=MeterConfigInstance, Path=MeterSelectedChangedCmd}" CommandParameter="{Binding ElementName=listviewMeter, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
<GridViewColumn
Width="40"
DisplayMemberBinding="{Binding StepNo}"
Header="序号" />
<GridViewColumn
Width="60"
DisplayMemberBinding="{Binding StartValue}"
Header="起始值" />
<GridViewColumn
Width="60"
DisplayMemberBinding="{Binding EndValue}"
Header="结束值" />
<GridViewColumn
Width="100"
DisplayMemberBinding="{Binding KeepTime, Converter={StaticResource SecToStrConverter}}"
Header="维持时间" />
</GridView>
</ListView.View>
<!-- 设置ListViewItem的背景色模拟网格效果 -->
<!--<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Background" Value="LightGray" />
</Style>
</ListView.ItemContainerStyle>-->
</ListView>
</Border>
</Grid>
</TabItem>
</TabControl>
</Grid>
</UserControl>