private void CreateAll() { // Count how many visible buttons are on each edge of each docker int[] nearCounts = new int[DockerCount]; int[] farCounts = new int[DockerCount]; // Create from the variable and the fixed collections CreateFromCollection(_variableSpecs, ref nearCounts, ref farCounts); CreateFromCollection(_fixedSpecs, ref nearCounts, ref farCounts); // If we are applying padding metrics if (_viewMetrics != null) { // Update the visible state of the edge spacers for (int i = 0; i < _viewMetrics.Length; i++) { // Only enable the spacer if there is at least one visible button on that edge bool farVisible = (farCounts[i] > 0); bool nearVisible = (nearCounts[i] > 0); ListSpacers spacer = _viewSpacers[i]; // The outside spacers are always present spacer[0].Visible = nearVisible; spacer[1].Visible = farVisible; if (UseInsideSpacers) { spacer[2].Visible = nearVisible; spacer[3].Visible = farVisible; } } } }
/// <summary> /// Perform once only construction. /// </summary> public void Construct() { // Only add button spacers if we have metrics to control them if (_viewMetrics != null) { // Add button spacers into each of the view dockers for (int i = 0; i < _viewMetrics.Length; i++) { // Get access to the matching docker/metrics/metric triple IPaletteMetric viewMetric = _viewMetrics[i]; PaletteMetricInt viewMetricIntOutside = _viewMetricIntOutside[i]; // Create storage for the spacers _viewSpacers[i] = new ListSpacers(); // Always create the outside edge spacers ViewLayoutMetricSpacer spacerL1 = new ViewLayoutMetricSpacer(viewMetric, viewMetricIntOutside); ViewLayoutMetricSpacer spacerR1 = new ViewLayoutMetricSpacer(viewMetric, viewMetricIntOutside); spacerL1.Visible = spacerR1.Visible = false; // Add the spacers to the docker instance AddSpacersToDocker(i, spacerL1, spacerR1); // Remember the spacers for future reference _viewSpacers[i].AddRange(new ViewLayoutMetricSpacer[] { spacerL1, spacerR1 }); if (UseInsideSpacers) { PaletteMetricInt viewMetricIntInside = _viewMetricIntInside[i]; // Create the inside edge spacers ViewLayoutMetricSpacer spacerL2 = new ViewLayoutMetricSpacer(viewMetric, viewMetricIntInside); ViewLayoutMetricSpacer spacerR2 = new ViewLayoutMetricSpacer(viewMetric, viewMetricIntInside); spacerL2.Visible = spacerR2.Visible = false; // Add them into the view docker instance AddSpacersToDocker(i, spacerL2, spacerR2); // Remember the spacers for future reference _viewSpacers[i].AddRange(new ViewLayoutMetricSpacer[] { spacerL2, spacerR2 }); } } } }