To simulate expected behaviour set the AutoLayout property to false and use the Resize event of GaugeControl:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace GaugeResizeApp {
public partial class TestForm : Form {
public TestForm() {
InitializeComponent();
gaugeControl1.Resize += OnGaugeControlResize;
OnGaugeControlResize(null, EventArgs.Empty);
}
void OnGaugeControlResize(object sender, EventArgs e) {
RectangleF bounds = CalcGaugeBounds(
gaugeControl1.ClientRectangle, new SizeF(250f, 106f), new SizeF(15f, 15f)
);
gaugeControl1.Gauges[0].Bounds = Rectangle.Round(bounds);
}
//
readonly float DefaultLayoutCellSize = 250f;
protected RectangleF CalcGaugeBounds(RectangleF layoutArea, SizeF gaugeSize, SizeF spacing) {
RectangleF contentRect = new RectangleF(
spacing.Width, spacing.Height,
layoutArea.Width - spacing.Width * 2, layoutArea.Height - spacing.Height * 2
);
float layoutCellSize = Math.Max(contentRect.Width, contentRect.Height);
SizeF absoluteCellSize = new SizeF(
layoutCellSize * DefaultLayoutCellSize / gaugeSize.Width,
layoutCellSize * DefaultLayoutCellSize / gaugeSize.Height
);
return new RectangleF(
contentRect.Left + (contentRect.Width - absoluteCellSize.Width) * 0.5f,
contentRect.Top + (contentRect.Height - absoluteCellSize.Height) * 0.5f,
absoluteCellSize.Width,
absoluteCellSize.Height
);
}
}
}