1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-05-31 22:41:37 +00:00

Fix crash when window panel sizes are off

The code could attempt to set a negative height for the windows in
the side panels.

(issue #108)
This commit is contained in:
Andy McFadden 2021-08-21 07:45:11 -07:00
parent f4bee76023
commit fc5f36885a

View File

@ -486,9 +486,11 @@ namespace SourceGen.WpfGui {
// Thanks: https://stackoverflow.com/q/35000893/294248
double totalHeight = leftPanel.RowDefinitions[0].ActualHeight +
leftPanel.RowDefinitions[2].ActualHeight;
leftPanel.RowDefinitions[0].Height = new GridLength(value, GridUnitType.Star);
leftPanel.RowDefinitions[2].Height = new GridLength(totalHeight - value,
GridUnitType.Star);
if (totalHeight > value) {
leftPanel.RowDefinitions[0].Height = new GridLength(value, GridUnitType.Star);
leftPanel.RowDefinitions[2].Height = new GridLength(totalHeight - value,
GridUnitType.Star);
}
}
}
public double SymbolsPanelHeight {
@ -496,9 +498,11 @@ namespace SourceGen.WpfGui {
set {
double totalHeight = rightPanel.RowDefinitions[0].ActualHeight +
rightPanel.RowDefinitions[2].ActualHeight;
rightPanel.RowDefinitions[0].Height = new GridLength(value, GridUnitType.Star);
rightPanel.RowDefinitions[2].Height = new GridLength(totalHeight - value,
GridUnitType.Star);
if (totalHeight > value) {
rightPanel.RowDefinitions[0].Height = new GridLength(value, GridUnitType.Star);
rightPanel.RowDefinitions[2].Height = new GridLength(totalHeight - value,
GridUnitType.Star);
}
}
}