[WIP] Scaling
Test / Run tests (push) Successful in 13s

This commit is contained in:
2026-08-13 23:47:43 +02:00
parent 2dee3a9ae9
commit c7f90889d8
24 changed files with 764 additions and 564 deletions
+14 -11
View File
@@ -5,7 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PamhagenSysCtrl.Windows"
Closed="OnClosed"
Title="Anlagensteuerung Pamhagen" Height="950" Width="1600" MinWidth="1500" MinHeight="950">
SizeChanged="OnSizeChanged"
Title="Anlagensteuerung Pamhagen"
Height="800" Width="1400" MinWidth="1000" MinHeight="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="19"/>
@@ -59,14 +61,15 @@
</Menu>
<Grid Grid.Row="1" ClipToBounds="True">
<Canvas x:Name="SchemeCanvas" Width="1550" Height="900" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True"
MouseMove="SchemeCanvas_MouseMove" MouseLeftButtonDown="SchemeCanvas_MouseLeftButtonDown" MouseLeftButtonUp="SchemeCanvas_MouseLeftButtonUp" Grid.ColumnSpan="2" Margin="25,0,0,0">
<Canvas x:Name="SchemeCanvas" VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True" Grid.ColumnSpan="2" Margin="25,0,0,0"
MouseMove="SchemeCanvas_MouseMove" MouseWheel="SchemeCanvas_MouseWheel"
MouseLeftButtonDown="SchemeCanvas_MouseLeftButtonDown" MouseLeftButtonUp="SchemeCanvas_MouseLeftButtonUp">
</Canvas>
<Border Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="10,10,20,20" Margin="0,0,-11,-11"
Background="WhiteSmoke"
BorderBrush="Gray" BorderThickness="1" CornerRadius="10">
<Grid>
<Grid x:Name="FastSelectButtonsRight">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="5"/>
@@ -156,7 +159,7 @@
<Border HorizontalAlignment="Left" VerticalAlignment="Bottom" Padding="60,15,15,30" Margin="-11,0,0,-11"
Background="WhiteSmoke"
BorderBrush="Gray" BorderThickness="1" CornerRadius="10">
<Grid>
<Grid x:Name="FastSelectButtonsLeft">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="2.5"/>
@@ -176,13 +179,13 @@
FontSize="14" FontWeight="Bold"
Click="FastSelectButton_EntryTroughStart_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center">Auffangwanne<LineBreak/><Run FontSize="18">Schnecke Start</Run></TextBlock>
<TextBlock TextAlignment="Center">Auffangwanne<LineBreak/><Run x:Name="FastSelectButton_EntryTrough_Start_Run" FontSize="18">Schnecke Start</Run></TextBlock>
</Button>
<Button x:Name="FastSelectButton_EntryTrough_Stop" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2"
FontSize="14" FontWeight="Bold"
Click="FastSelectButton_EntryTroughStop_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center">Auffangwanne<LineBreak/><Run FontSize="18">Schnecke Stop</Run></TextBlock>
<TextBlock TextAlignment="Center">Auffangwanne<LineBreak/><Run x:Name="FastSelectButton_EntryTrough_Stop_Run" FontSize="18">Schnecke Stop</Run></TextBlock>
</Button>
@@ -199,26 +202,26 @@
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP2_Stop_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run FontSize="24">MP2</Run><LineBreak/>Stop</TextBlock>
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP2_Stop_Run" FontSize="24">MP2</Run><LineBreak/>Stop</TextBlock>
</Button>
<Button x:Name="FastSelectButton_MP2_Forward" Grid.Column="0" Grid.Row="5"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP2_Forward_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run FontSize="24">MP2</Run><LineBreak/><Run x:Name="MP2_Target">Vor</Run></TextBlock>
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP2_Forward_Run" FontSize="24">MP2</Run><LineBreak/><Run x:Name="MP2_Target">Vor</Run></TextBlock>
</Button>
<Button x:Name="FastSelectButton_MP1_Stop" Grid.Column="3" Grid.Row="4"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP1_Stop_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run FontSize="24">MP1</Run><LineBreak/>Stop</TextBlock>
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP1_Stop_Run" FontSize="24">MP1</Run><LineBreak/>Stop</TextBlock>
</Button>
<Button x:Name="FastSelectButton_MP1_Forward" Grid.Column="3" Grid.Row="5"
FontSize="16" FontWeight="Bold"
Click="FastSelectButton_MP1_Forward_Click" MouseEnter="FastSelectButton_Enter" MouseLeave="FastSelectButton_Leave"
BorderThickness="2">
<TextBlock TextAlignment="Center"><Run FontSize="24">MP1</Run><LineBreak/><Run x:Name="MP1_Target">Vor</Run></TextBlock>
<TextBlock TextAlignment="Center"><Run x:Name="FastSelectButton_MP1_Forward_Run" FontSize="24">MP1</Run><LineBreak/><Run x:Name="MP1_Target">Vor</Run></TextBlock>
</Button>
</Grid>
</Border>
@@ -16,6 +16,9 @@ namespace PamhagenSysCtrl.Windows {
private ISet<INode>? _lastSelected;
private ISet<INode>? _hover;
public double Scale { get; set; } = 5;
public double RoundedScale => Math.Round(Scale * 2) / 2;
public Path? HoveringPath {
get {
foreach (var b in FastSelectPaths.Where(b => b.Key.IsMouseOver)) {
@@ -44,7 +47,7 @@ namespace PamhagenSysCtrl.Windows {
InitializeComponent();
Menu_Help_CheckForUpdates.IsEnabled = App.Config.UpdateUrl != null;
Graph = new();
Graph.Draw(SchemeCanvas);
Graph.Draw(SchemeCanvas, RoundedScale);
FastSelectPaths = new Dictionary<Button, (ISource, Pump, ISink)> {
[FastSelectButton_MW1_Press1] = (Graph.MW1, Graph.MP1, Graph.Press1),
[FastSelectButton_MW2_Press1] = (Graph.MW2, Graph.MP2, Graph.Press1),
@@ -216,6 +219,93 @@ namespace PamhagenSysCtrl.Windows {
}
}
private void OnSizeChanged(object sender, SizeChangedEventArgs evt) {
var rx = evt.NewSize.Width / 1550.0;
var ry = evt.NewSize.Height / 900.0;
var r = Math.Min(rx, ry);
Scale = r * 5;
Graph.Scale(RoundedScale);
if (RoundedScale < 4) {
(FastSelectButtonsLeft.Parent as Border)?.Visibility = Visibility.Hidden;
(FastSelectButtonsRight.Parent as Border)?.Visibility = Visibility.Hidden;
} else if (RoundedScale <= 5) {
(FastSelectButtonsLeft.Parent as Border)?.Visibility = Visibility.Visible;
FastSelectButtonsLeft.ColumnDefinitions[0].Width = new(120);
FastSelectButtonsLeft.ColumnDefinitions[3].Width = new(120);
FastSelectButtonsLeft.RowDefinitions[0].Height = new(45);
FastSelectButtonsLeft.RowDefinitions[2].Height = new(40);
FastSelectButtonsLeft.RowDefinitions[4].Height = new(55);
FastSelectButtonsLeft.RowDefinitions[5].Height = new(55);
(FastSelectButtonsRight.Parent as Border)?.Visibility = Visibility.Visible;
foreach (var col in FastSelectButtonsRight.ColumnDefinitions) {
if (col.Width.Value <= 5) continue;
col.Width = new(120);
}
foreach (var row in FastSelectButtonsRight.RowDefinitions) {
if (row.Height.Value <= 5) continue;
row.Height = new(40);
}
foreach (var b in FastSelectPaths.Keys) {
b.FontSize = 14;
}
FastSelectButton_EntryTrough_Start.FontSize = 12;
FastSelectButton_EntryTrough_Start_Run.FontSize = 14;
FastSelectButton_EntryTrough_Stop.FontSize = 12;
FastSelectButton_EntryTrough_Stop_Run.FontSize = 14;
FastSelectButton_MW1.FontSize = 14;
FastSelectButton_MW2.FontSize = 14;
FastSelectButton_MP1_Stop.FontSize = 14;
FastSelectButton_MP1_Stop_Run.FontSize = 18;
FastSelectButton_MP1_Forward.FontSize = 14;
FastSelectButton_MP1_Forward_Run.FontSize = 18;
FastSelectButton_MP2_Stop.FontSize = 14;
FastSelectButton_MP2_Stop_Run.FontSize = 18;
FastSelectButton_MP2_Forward.FontSize = 14;
FastSelectButton_MP2_Forward_Run.FontSize = 18;
} else {
(FastSelectButtonsLeft.Parent as Border)?.Visibility = Visibility.Visible;
FastSelectButtonsLeft.ColumnDefinitions[0].Width = new(160);
FastSelectButtonsLeft.ColumnDefinitions[3].Width = new(160);
FastSelectButtonsLeft.RowDefinitions[0].Height = new(60);
FastSelectButtonsLeft.RowDefinitions[2].Height = new(50);
FastSelectButtonsLeft.RowDefinitions[4].Height = new(80);
FastSelectButtonsLeft.RowDefinitions[5].Height = new(80);
(FastSelectButtonsRight.Parent as Border)?.Visibility = Visibility.Visible;
foreach (var col in FastSelectButtonsRight.ColumnDefinitions) {
if (col.Width.Value <= 5) continue;
col.Width = new(160);
}
foreach (var row in FastSelectButtonsRight.RowDefinitions) {
if (row.Height.Value <= 5) continue;
row.Height = new(50);
}
foreach (var b in FastSelectPaths.Keys) {
b.FontSize = 16;
}
FastSelectButton_EntryTrough_Start.FontSize = 14;
FastSelectButton_EntryTrough_Start_Run.FontSize = 18;
FastSelectButton_EntryTrough_Stop.FontSize = 14;
FastSelectButton_EntryTrough_Stop_Run.FontSize = 18;
FastSelectButton_MW1.FontSize = 16;
FastSelectButton_MW2.FontSize = 16;
FastSelectButton_MP1_Stop.FontSize = 16;
FastSelectButton_MP1_Stop_Run.FontSize = 24;
FastSelectButton_MP1_Forward.FontSize = 16;
FastSelectButton_MP1_Forward_Run.FontSize = 24;
FastSelectButton_MP2_Stop.FontSize = 16;
FastSelectButton_MP2_Stop_Run.FontSize = 24;
FastSelectButton_MP2_Forward.FontSize = 16;
FastSelectButton_MP2_Forward_Run.FontSize = 24;
}
UpdateScheme(Mouse.GetPosition(SchemeCanvas), Mouse.LeftButton == MouseButtonState.Pressed);
}
private void SchemeCanvas_MouseWheel(object sender, MouseWheelEventArgs evt) {
Scale = Math.Max(1, Math.Min(20, Scale + evt.Delta / 500.0));
Graph.Scale(RoundedScale);
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
}
private void SchemeCanvas_MouseMove(object sender, MouseEventArgs evt) {
UpdateScheme(evt.GetPosition(SchemeCanvas), evt.LeftButton == MouseButtonState.Pressed);
}
@@ -401,7 +491,7 @@ namespace PamhagenSysCtrl.Windows {
SetFastSelectButton(b.Key, 0, false);
}
_hover = Graph.GetHover(pos.X, pos.Y);
_hover = Graph.GetHover(pos.X, pos.Y, RoundedScale);
var hoverButtons = FastSelectPaths.Where(b => b.Key.IsMouseOver).ToDictionary();
Path? hoverPathDeactivate = null;
if (App.Plant?.ManualControlMode ?? false) {