private void ShowComponents(int start, bool save = true) { if (save) { SaveCurrentValues(); } for (var row = 0; row < _totalChannelsDisplayed; row++) { _labels[row].Text = _sourceProfile.GetChannelName(start + row); _labels[row].BackColor = _sourceProfile.GetChannelColor(start + row); _labels[row].ForeColor = _labels[row].BackColor.GetForeColor(); _textBoxes[row].Text = _destinationTextBoxText[_sourceProfile.GetChannelLocation(start + row)]; if (!_isPreview) { continue; } var s = _textBoxes[row].Text.Split(_splitChar, StringSplitOptions.RemoveEmptyEntries); var col = 0; foreach (var channel in s) { var channelNum = int.Parse(channel); var c = Controls.Find("r" + row + "c" + col, true)[0]; if (channelNum < _destinationNatural.GetChannelCount()) { c.Text = _destinationNatural.GetChannelName(channelNum); c.BackColor = _destinationNatural.GetChannelColor(channelNum); c.ForeColor = c.BackColor.GetForeColor(); c.Visible = true; } col++; } for (; col < _maxDestinationCount; col++) { Controls.Find("r" + row + "c" + col, true)[0].Visible = false; } } _currentTopChannelIndex = start; vsb.Value = start; }
private void PopulateDestinationList() { var maxSize = lbDestination.Width; using (var g = lbDestination.CreateGraphics()) { lbDestination.Items.Clear(); for (var i = 0; i < _destinationProfile.GetChannelCount(); i++) { var name = _destinationProfile.GetChannelName(i); lbDestination.Items.Add(name); var size = g.MeasureString(name, lbDestination.Font); if (size.Width > maxSize) { maxSize = (int)size.Width; } } } lbDestination.HorizontalExtent = maxSize; }