private void PopulateFramerates(FramerateGroup framerateGroup) { cmbFramerate.Items.Clear(); int match = -1; foreach (MediaTypeSelection selectable in framerateGroup.Framerates.Values) { cmbFramerate.Items.Add(selectable); if (Math.Abs(selectedFramerate - selectable.Framerate) < 0.001) { match = cmbFramerate.Items.Count - 1; } } if (match != -1) { cmbFramerate.SelectedIndex = match; } else if (cmbFramerate.Items.Count > 0) { cmbFramerate.SelectedIndex = 0; } }
/// <summary> /// Add the selectable to the hierarchy, creating parents as needed. /// </summary> private void Import(MediaType mt, float rate, MediaTypeSelection selectable) { if (rate <= 0) { return; } string formatKey = mt.Compression; if (!formatGroups.ContainsKey(formatKey)) { formatGroups.Add(formatKey, new SizeGroup(mt.Compression)); } SizeGroup sizeGroup = formatGroups[mt.Compression]; string sizeKey = string.Format("{0}×{1}", mt.FrameSize.Width, mt.FrameSize.Height); if (!sizeGroup.FramerateGroups.ContainsKey(sizeKey)) { sizeGroup.FramerateGroups.Add(sizeKey, new FramerateGroup(mt.FrameSize)); } FramerateGroup framerateGroup = sizeGroup.FramerateGroups[sizeKey]; if (framerateGroup.Framerates.ContainsKey(rate)) { // Duplicate {format, size, framerate} triplet. return; } framerateGroup.Framerates.Add(rate, selectable); }
private void cmbImageSize_SelectedIndexChanged(object sender, EventArgs e) { if (!canStreamConfig) { return; } FramerateGroup framerateGroup = cmbImageSize.SelectedItem as FramerateGroup; if (framerateGroup == null) { return; } PopulateFramerates(framerateGroup); }