void RebuildUserInterface() { SuspendLayout(); ClearStackControls(); IEnumerable <PathRecord> sortedCollection = _core.Sorted(SelectedSorting); IList <PathRecord> pathRecords = sortedCollection as IList <PathRecord> ?? sortedCollection.ToList(); int collectionCount = (HideInaccessablePaths) ? pathRecords.Count(pr => pr.Capacity.Bytes > 0) : pathRecords.Count; int diskCount = (collectionCount < MaxItemListCount) ? collectionCount : MaxItemListCount; int rowOneHeight = tableLayout.GetRowHeights()[1] + tableLayout.GetRowHeights()[2]; int borderWidth = (Width - ClientSize.Width) / 2; int titlebarHeight = Height - ClientSize.Height - (2 * borderWidth); int height = (DiskTile.HeightPixels * diskCount) + rowOneHeight + (2 * borderWidth) + titlebarHeight + diskStack.Padding.Top + diskStack.Padding.Bottom; SetFixedFormSize(FormWidth + (2 * borderWidth), height); PositionForm(); foreach (var pc in pathRecords) { var newTile = new DiskTile(pc) { Padding = new Padding(0) }; //subscribe to the events newTile.RemoveRequested += RemovePathUsingTileObject; newTile.AddNewPath += AddNewPath; newTile.PropertiesChanged += TilePropertiesChanged; diskStack.Controls.Add(newTile); } ResumeLayout(true); }