Files
XplorePlane/XP.Common/Controls/VirtualJoystick.xaml
T

99 lines
6.7 KiB
XML

<UserControl x:Class="XP.Common.Controls.VirtualJoystick"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:XP.Common.Controls"
mc:Ignorable="d"
d:DesignWidth="200" d:DesignHeight="200"
Cursor="Hand">
<Grid x:Name="PART_Root">
<!-- ========== 双轴模式背景:圆形 | DualAxis background: Circle ========== -->
<Ellipse x:Name="DualAxisBackground"
Fill="#FFF5F5F5" Stroke="#FFCCCCCC" StrokeThickness="1.5" />
<!-- ========== 单轴模式背景:腰圆 | SingleAxisY background: Capsule ========== -->
<Border x:Name="SingleAxisBackground"
Background="#FFF5F5F5" BorderBrush="#FFCCCCCC" BorderThickness="1.5"
CornerRadius="20" Visibility="Collapsed" />
<!-- 十字形背景虚线(双轴显示水平+垂直,单轴只显示垂直)| Cross-shaped dashed lines -->
<Line x:Name="HorizontalLine" X1="0" Y1="0" X2="1" Y2="0" Stretch="Fill"
Stroke="#FFD0D0D0" StrokeThickness="1" StrokeDashArray="4 2"
VerticalAlignment="Center" IsHitTestVisible="False" />
<Line X1="0" Y1="0" X2="0" Y2="1" Stretch="Fill"
Stroke="#FFD0D0D0" StrokeThickness="1" StrokeDashArray="4 2"
HorizontalAlignment="Center" IsHitTestVisible="False" />
<!-- 四向图标区域 | Four-directional icon area -->
<Grid IsHitTestVisible="False" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 上方图标 | Top icons -->
<ContentPresenter x:Name="DefaultTopPresenter" Grid.Row="0" Grid.Column="1"
Content="{Binding DefaultTopIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Center" VerticalAlignment="Top" />
<ContentPresenter x:Name="LeftTopPresenter" Grid.Row="0" Grid.Column="1"
Content="{Binding LeftButtonTopIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Center" VerticalAlignment="Top" Visibility="Collapsed" />
<ContentPresenter x:Name="RightTopPresenter" Grid.Row="0" Grid.Column="1"
Content="{Binding RightButtonTopIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Center" VerticalAlignment="Top" Visibility="Collapsed" />
<!-- 下方图标 | Bottom icons -->
<ContentPresenter x:Name="DefaultBottomPresenter" Grid.Row="2" Grid.Column="1"
Content="{Binding DefaultBottomIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Center" VerticalAlignment="Bottom" />
<ContentPresenter x:Name="LeftBottomPresenter" Grid.Row="2" Grid.Column="1"
Content="{Binding LeftButtonBottomIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Visibility="Collapsed" />
<ContentPresenter x:Name="RightBottomPresenter" Grid.Row="2" Grid.Column="1"
Content="{Binding RightButtonBottomIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Visibility="Collapsed" />
<!-- 左方图标 | Left icons -->
<ContentPresenter x:Name="DefaultLeftPresenter" Grid.Row="1" Grid.Column="0"
Content="{Binding DefaultLeftIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Left" VerticalAlignment="Center" />
<ContentPresenter x:Name="LeftLeftPresenter" Grid.Row="1" Grid.Column="0"
Content="{Binding LeftButtonLeftIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Collapsed" />
<ContentPresenter x:Name="RightLeftPresenter" Grid.Row="1" Grid.Column="0"
Content="{Binding RightButtonLeftIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Collapsed" />
<!-- 右方图标 | Right icons -->
<ContentPresenter x:Name="DefaultRightPresenter" Grid.Row="1" Grid.Column="2"
Content="{Binding DefaultRightIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Right" VerticalAlignment="Center" />
<ContentPresenter x:Name="LeftRightPresenter" Grid.Row="1" Grid.Column="2"
Content="{Binding LeftButtonRightIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="Collapsed" />
<ContentPresenter x:Name="RightRightPresenter" Grid.Row="1" Grid.Column="2"
Content="{Binding RightButtonRightIcon, RelativeSource={RelativeSource AncestorType=local:VirtualJoystick}}"
HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="Collapsed" />
</Grid>
<!-- 中心操控点 | Center thumb -->
<Ellipse x:Name="PART_Thumb" Width="28" Height="28"
Fill="#FF4A90D9" Stroke="#FF2A6AB0" StrokeThickness="2"
HorizontalAlignment="Center" VerticalAlignment="Center"
Cursor="SizeAll" IsHitTestVisible="False">
<Ellipse.Effect>
<DropShadowEffect Color="#40000000" BlurRadius="4" ShadowDepth="1" Opacity="0.5" />
</Ellipse.Effect>
</Ellipse>
</Grid>
</UserControl>