TProPCMonitor/LoraGamepad/Views/TProView.axaml

113 lines
6.6 KiB
XML

<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:LoraGamepad.ViewModels"
xmlns:eventBinder="clr-namespace:EventBinder;assembly=EventBinder.Avalonia"
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="400"
x:Class="LoraGamepad.Views.TProView">
<UserControl.DataContext>
<viewModels:TProViewModel/>
</UserControl.DataContext>
<!-- 样式设置 -->
<UserControl.Styles>
<Style Selector="Button.pad">
<Setter Property="Background" Value="{DynamicResource DarkBlueBrush}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="18"/>
</Style>
<Style Selector="Button.pad:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource BrightRedBrush}"/>
<Setter Property="TextBlock.Foreground" Value="White"/>
</Style>
<Style Selector="Button.open">
<Setter Property="Background" Value="{DynamicResource DarkBlueBrush}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="18"/>
</Style>
<Style Selector="Button.close">
<Setter Property="Background" Value="{DynamicResource DarkRedBrush}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="18"/>
</Style>
<Style Selector="Button.open:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource BrightBlueBrush}"/>
<Setter Property="TextBlock.Foreground" Value="White"/>
</Style>
<Style Selector="Button.close:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource BrightRedBrush}"/>
<Setter Property="TextBlock.Foreground" Value="White"/>
</Style>
<Style Selector="Slider">
<Setter Property="TickFrequency" Value="10"/>
<Setter Property="TickPlacement" Value="BottomRight"/>
<Setter Property="Maximum" Value="100"/>
<Setter Property="Minimum" Value="-100"/>
</Style>
</UserControl.Styles>
<!-- 页面布局 -->
<Grid RowDefinitions="60,*,40,2*">
<Grid Grid.Row="0" Background="Blue" ColumnDefinitions="*,2*,2*,*">
<Slider Grid.Column="0" Width="80" HorizontalAlignment="Center"
Value="{Binding SliderValue.LeftUpValue}"/>
<ComboBox Grid.Column="1" SelectedIndex="0" VerticalAlignment="Center" Width="100" HorizontalAlignment="Right" Margin="5,0"
Items="{Binding PortList}"
SelectedItem="{Binding PortSelectItem}"
PointerPressed="{eventBinder:EventBinding OnPortListComboBoxPressed}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="18" Foreground="White" Text="{Binding PortName}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button Grid.Column="2" Classes="open" Command="{Binding OpenPort}" IsVisible="{Binding IsOpenPortButtonVisible}"
HorizontalAlignment="Left" Margin="5,0,0,0" Content="打开串口" HorizontalContentAlignment="Center" Width="100"
Name="BtnPortOpen">
</Button>
<Button Grid.Column="2" Classes="close" Command="{Binding ClosePort}" IsVisible="{Binding IsClosePortButtonVisible}"
HorizontalAlignment="Left" Margin="5,0,0,0" Content="关闭串口" HorizontalContentAlignment="Center" Width="100"
Name="BtnPortClose">
</Button>
<Button Grid.Column="3" Classes="pad" Width="80" Height="40" HorizontalAlignment="Left"
IsPressed="{Binding BtnIsPressed.BtnRightDown}"/>
</Grid>
<Grid Grid.Row="1" Background="Gray" ColumnDefinitions="2*,*,4*,*,2*">
<Button Grid.Column="0" Classes="pad" Width="80" Height="60" HorizontalAlignment="Center"
IsPressed="{Binding BtnIsPressed.BtnLeftUp}"/>
<Slider Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center"
Value="{Binding SliderValue.MidLeftValue}"/>
<Slider Grid.Column="3" Orientation="Vertical" HorizontalAlignment="Center"
Value="{Binding SliderValue.MidRightValue}"/>
<Button Grid.Column="4" Classes="pad" Width="80" Height="60" HorizontalAlignment="Center"
IsPressed="{Binding BtnIsPressed.BtnRightUp}"/>
</Grid>
<Grid Grid.Row="2" Background="Yellow">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Classes="pad" IsPressed="{Binding BtnIsPressed.BtnModel1 }" Width="40" Margin="10"/>
<Button Classes="pad" IsPressed="{Binding BtnIsPressed.BtnModel2 }" Width="40" Margin="10"/>
<Button Classes="pad" IsPressed="{Binding BtnIsPressed.BtnModel3 }" Width="40" Margin="10"/>
<Button Classes="pad" IsPressed="{Binding BtnIsPressed.BtnModel4 }" Width="40" Margin="10"/>
<Button Classes="pad" IsPressed="{Binding BtnIsPressed.BtnModel5 }" Width="40" Margin="10"/>
<Button Classes="pad" IsPressed="{Binding BtnIsPressed.BtnModel6 }" Width="40" Margin="10"/>
</StackPanel>
</Grid>
<Grid Grid.Row="3" Background="Green" ColumnDefinitions="*,2*,*">
<Grid Grid.Column="0">
<Slider VerticalAlignment="Center"
Value="{Binding SliderValue.LeftVerticalValue}"/>
<Slider Orientation="Vertical" HorizontalAlignment="Center"
Value="{Binding SliderValue.LeftHorizonValue}"/>
</Grid>
<Grid Grid.Column="1" Background="Purple">
<TextBox Text="Hello T-Pro!"/>
</Grid>
<Grid Grid.Column="2">
<Slider VerticalAlignment="Center"
Value="{Binding SliderValue.RightHorizonValue}"/>
<Slider Orientation="Vertical" HorizontalAlignment="Center"
Value="{Binding SliderValue.RightVerticalValue}"/>
</Grid>
</Grid>
</Grid>
</UserControl>