@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user