Fix calculation for automatic positioning and rendering scales

master
LeapwardKoex 2024-11-09 20:30:58 +13:00
parent 9d06a0293a
commit a01cdd6dfa
2 changed files with 53 additions and 49 deletions

View File

@ -36,9 +36,9 @@ class TouchPanelPositionManager
{
// Calculate the desired size and position based on the other application's window
var renderRect = GetLargest916Rect(rect);
var height = renderRect.Width;
var height = renderRect.Height;
var left = rect.Left + (rect.Right - rect.Left - renderRect.Width) / 2; // Center horizontally
var top = rect.Bottom - height;
var top = renderRect.Top;
return new Rect(left, top, renderRect.Width, height);
}
}

View File

@ -10,14 +10,18 @@
AllowsTransparency="True" WindowStyle="None" Background="Transparent"
>
<Border Background="#01000000">
<StackPanel HorizontalAlignment="Left">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border x:Name="DragWindowHandle" HorizontalAlignment="Left" VerticalAlignment="Top"
Height="50" Background="White" MouseLeftButtonDown="DragBar_MouseLeftButtonDown"
Cursor="SizeAll" Width="70">
<Label FontSize="24" Content="{Binding LbTouchPanelDrag}" d:Content="Drag" />
</Border>
<Viewbox Stretch="Uniform" Opacity="1" Height="1230" VerticalAlignment="Bottom">
<DockPanel VerticalAlignment="Bottom">
<Viewbox Stretch="Uniform" Opacity="1">
<Canvas x:Name="TouchCanvas" Width="1440" Height="1440">
<Polygon Canvas.Left="699" Canvas.Top="6" Points="0,0 39,0 111,5 113,6 111,24 80,243 77,243 63,229 56,221 23,188 16,194 -34,244 -36,244 -70,4 -70,3 0,0" PreviewTouchDown="Element_TouchDown" PreviewTouchMove="Element_TouchMove" PreviewTouchUp="Element_TouchUp" Tag="{x:Static local:TouchValue.D1}" Fill="White" />
@ -60,15 +64,15 @@
<Border x:Name="ResizeGrip"
Width="150" Height="90" Background="White"
MouseDown="ResizeGrip_MouseDown" Canvas.Left="1290" Canvas.Top="1350" HorizontalAlignment="Center" VerticalAlignment="Top">
<Border x:Name="ResizeGrip" Width="150" Height="90" Background="White" MouseDown="ResizeGrip_MouseDown" Canvas.Left="1290" Canvas.Top="1350" HorizontalAlignment="Center" VerticalAlignment="Top">
<Label FontSize="50" Content="{Binding LbTouchPanelResize}" d:Content="Resize" />
</Border>
</Canvas>
</Viewbox>
</StackPanel>
</DockPanel>
</Grid>
</Border>