plcsharp/PLCSharpWpf/VVMs/Homepage/Homepage.xaml

120 lines
6.3 KiB
XML

<UserControl x:Class="PLCSharp.VVMs.Homepage.Homepage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cvt="clr-namespace:PLCSharp.Core.Tools"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:PLCSharp.VVMs.Homepage"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:HomepageViewModel}"
d:Height="600" d:Width="1000"
Background="AliceBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Border Background="{Binding GlobalModel.TitleState.Background}">
<Viewbox>
<TextBlock Margin="30,0" Text="{Binding GlobalModel.TitleState.Info}" />
</Viewbox>
</Border>
<Grid Name="MainGrid" Grid.Row="1" />
<StackPanel Grid.RowSpan="2" Grid.Column="1">
<GroupBox Header="当前配方">
<StackPanel>
<Label Content="{Binding GlobalModel.CurrentRecipe.Name}" />
</StackPanel>
</GroupBox>
<GroupBox Header="模式">
<StackPanel>
<Border Padding="10,5" Background="{Binding ElementName=ModeEnumChildElement, Path=Background}" CornerRadius="10">
<TextBlock x:Name="ModeEnumChildElement" Text="{Binding GlobalModel.ModeState.ModeEnum}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center">
</Setter>
<Style.Triggers>
<Trigger Property="Text" Value="Manual">
<Setter Property="Background" Value="Yellow" />
</Trigger>
<Trigger Property="Text" Value="Production">
<Setter Property="Background" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Button Height="30" Margin="10"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Manual" Content="手动模式" />
<Button Height="30" Margin="10"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Production" Content="生产模式" />
</StackPanel>
</GroupBox>
<GroupBox Header="状态">
<StackPanel>
<Border Padding="10,5" Background="{Binding ElementName=MyChildElement, Path=Background}" CornerRadius="10">
<TextBlock x:Name="MyChildElement" Text="{Binding GlobalModel.ModeState.StateEnum}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center">
</Setter>
<Style.Triggers>
<Trigger Property="Text" Value="Execute">
<Setter Property="Background" Value="Lime" />
</Trigger>
<Trigger Property="Text" Value="Idle">
<Setter Property="Background" Value="PowderBlue" />
</Trigger>
<Trigger Property="Text" Value="Stopped">
<Setter Property="Background" Value="Yellow" />
</Trigger>
<Trigger Property="Text" Value="Aborted">
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
<Button Height="30" Margin="10"
Background="LightGreen"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Start" Content="启动" />
<Button Height="30" Margin="10"
Background="Pink"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Stop" Content="停止" />
<Button Height="30" Margin="10"
Background="LightYellow"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Reset" Content="复位" />
<Button Height="30" Margin="10"
Background="LightBlue"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Clear" Content="清除" />
<Button Height="30" Margin="10"
Background="LightCoral"
Command="{Binding GlobalModel.ModeState.ViewCommand}"
CommandParameter="Abort" Content="中止" />
</StackPanel>
</GroupBox>
</StackPanel>
</Grid>
</UserControl>