From e2039f9f995bf2b4a9e204c864251717454946d4 Mon Sep 17 00:00:00 2001 From: Van Date: Wed, 5 Apr 2017 16:05:24 -0700 Subject: [PATCH] Adjusted height of camera window. --- Controls/CameraWindow.cs | 4 ++-- Controls/LayoutPanel.cs | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Controls/CameraWindow.cs b/Controls/CameraWindow.cs index 096c0ee2..ca93eaeb 100644 --- a/Controls/CameraWindow.cs +++ b/Controls/CameraWindow.cs @@ -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; @@ -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; diff --git a/Controls/LayoutPanel.cs b/Controls/LayoutPanel.cs index 6c5b03f8..49e65144 100644 --- a/Controls/LayoutPanel.cs +++ b/Controls/LayoutPanel.cs @@ -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; } } } @@ -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;