Skip to content

Commit

Permalink
Fixed negative Y screens on PositionsControl
Browse files Browse the repository at this point in the history
  • Loading branch information
distrohelena committed Jan 25, 2019
1 parent 72c429a commit fa59585
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Master/Nucleus.Coop.App/Controls/Steps/PositionsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,29 @@ private void UpdateScreens() {
}

screensArea = new RectangleF(10, 50 + Height * 0.2f + 10, Width - 20, Height * 0.5f);
if (totalBounds.Width > totalBounds.Height) {

float actualHeight = totalBounds.Height;
float actualWidth = totalBounds.Width;

if (actualWidth > actualHeight) {
// horizontal monitor setup
scale = screensArea.Width / (float)totalBounds.Width;
scale = screensArea.Width / actualWidth;
if (totalBounds.Height * scale > screensArea.Height) {
scale = screensArea.Height / (float)totalBounds.Height;
scale = screensArea.Height / actualHeight;
}
} else {
// vertical monitor setup
scale = screensArea.Height / (float)totalBounds.Height;
scale = screensArea.Height / actualHeight;
if (totalBounds.Width * scale > screensArea.Width) {
scale = screensArea.Width / (float)totalBounds.Width;
scale = screensArea.Width / actualWidth;
}
}

Rectangle scaledBounds = RectangleUtil.Scale(totalBounds, scale);
scaledBounds.X = (int)screensArea.X;
scaledBounds.Y = (int)screensArea.Y;
//scaledBounds = RectangleUtil.Center(scaledBounds, RectangleUtil.Float(0, this.Height * 0.25f, this.Width, this.Height * 0.7f));

int minX = 0;
int minY = 0;
for (int i = 0; i < screens.Length; i++) {
UserScreen screen = screens[i];
Expand All @@ -310,16 +314,19 @@ private void UpdateScreens() {
Rectangle uiBounds = new Rectangle(bounds.X, bounds.Y + scaledBounds.Y, bounds.Width, bounds.Height);
screen.UIBounds = uiBounds;

minY = Math.Min(minY, uiBounds.X);
minX = Math.Min(minX, bounds.X);
minY = Math.Min(minY, bounds.Y);
}

// remove negative monitors
minX = -minX;
minY = -minY;
for (int i = 0; i < screens.Length; i++) {
UserScreen screen = screens[i];

Rectangle uiBounds = screen.UIBounds;
uiBounds.X += minY + scaledBounds.X;
uiBounds.X += minX + scaledBounds.X;
uiBounds.Y += minY;
screen.UIBounds = uiBounds;
screen.SwapTypeBounds = RectangleUtil.Float(uiBounds.X, uiBounds.Y, uiBounds.Width * 0.1f, uiBounds.Width * 0.1f);
}
Expand Down

0 comments on commit fa59585

Please sign in to comment.