public void CalculateClientAreaAndClientRect() { int innerWidth = Width - 2; int innerHeight = Height - 2; Properties["ClientArea"] = $"0, 0, {innerWidth}, {innerHeight}"; int splitDividerWidth = 5; // The total width covered by all the splits int maxSplitWidth = innerWidth - ((Splits.Count() - 1) * splitDividerWidth); int currentWidthOffset = 0; int avgSplitWidth = maxSplitWidth / Splits.Count(); if (Splits.Count == 1) { Splits[0].Properties["ClientRect"] = $"{currentWidthOffset}, 0, {innerWidth}, {innerHeight}"; } else { int startIndex = 0; // Add 1 to first split's width if maxSplitWidth can't be divided exactly by the number of splits if (maxSplitWidth % Splits.Count() != 0) { Splits[0].Properties["ClientRect"] = $"{currentWidthOffset}, 0, {avgSplitWidth + 1}, {innerHeight}"; currentWidthOffset += avgSplitWidth + 1 + splitDividerWidth; startIndex = 1; } for (int i = startIndex; i < Splits.Count; i++) { Splits[i].Properties["ClientRect"] = $"{currentWidthOffset}, 0, {avgSplitWidth}, {innerHeight}"; currentWidthOffset += avgSplitWidth + splitDividerWidth; } } }