Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted height of camera window. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Controls/CameraWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ internal Rectangle RC
cr.X += 1;
cr.Y += 1;
cr.Width = Math.Max(cr.Width - 2, 2);
cr.Height = Math.Max(cr.Height - 26, 26);
cr.Height = Math.Max(cr.Height - 2, 2);

_rc = Helper.GetArea(cr, Camera.Width, Camera.Height);
return _rc;
Expand All @@ -2532,7 +2532,7 @@ internal Rectangle RC
_rc.X += 1;
_rc.Y += 1;
_rc.Width = Math.Max(_rc.Width - 2, 2);
_rc.Height = Math.Max(_rc.Height - 26, 26);
_rc.Height = Math.Max(_rc.Height - 2, 2);


return _rc;
Expand Down
17 changes: 8 additions & 9 deletions Controls/LayoutPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void LayoutObjects(int w, int h)
if (bmp != null)
{
p.Width = bmp.Width + 2;
p.Height = bmp.Height + 32;
p.Height = bmp.Height + 2;
}
}
}
Expand Down Expand Up @@ -574,32 +574,31 @@ public void Minimize(object obj, bool tocontents)
}
}

public void LayoutOptimised()
public void LayoutOptimized(double aspectRatio = 1.333)
{
double numberCameras = MainForm.Cameras.Count;
int useX = 320, useY = 200;
int dispArea = Width * Height;
int lastArea = dispArea;


for (int y = 1; y <= numberCameras; y++)
{
int camX = y;
var camY = (int)Math.Round((numberCameras / y) + 0.499999999, 0);

int dispWidth = Width / camX;
int dispHeight = dispWidth / 4 * 3;
int camArea = (int)numberCameras * (dispWidth * (dispHeight + 40));
if (((dispArea - camArea) <= lastArea) && ((dispArea - camArea) > 0) && (((camY * (dispHeight + 40)) < Height)))
int dispHeight = Convert.ToInt32(dispWidth / aspectRatio);
int camArea = (int)numberCameras * (dispWidth * (dispHeight + 2));
if (((dispArea - camArea) <= lastArea) && ((dispArea - camArea) > 0) && (((camY * (dispHeight + 2)) < Height)))
{
useX = dispWidth;
useY = dispHeight;
lastArea = dispArea - camArea;
}

dispHeight = (Height - (camY * 40)) / camY;
dispWidth = dispHeight * 4 / 3;
camArea = (int)numberCameras * (dispWidth * (dispHeight + 40));
dispHeight = (Height - (camY * 2)) / camY;
dispWidth = Convert.ToInt32(dispHeight * aspectRatio);
camArea = (int)numberCameras * (dispWidth * (dispHeight + 2));
if (((dispArea - camArea) <= lastArea) && ((dispArea - camArea) > 0) && (((camX * dispWidth) < Width)))
{
useX = dispWidth;
Expand Down