void DisplaySpectrum(int scanIndex) { if (!TopographForm.Instance.EnsureMsDataFile(PeptideFileAnalysis.MsDataFile, true)) { return; } SpectrumForm spectrumForm; spectrumForm = new SpectrumForm(PeptideFileAnalysis.MsDataFile) { ScanIndex = scanIndex, }; spectrumForm.SetPeptideAnalysis(PeptideAnalysis); spectrumForm.Show(TopLevelControl); double minMz = 2000; double maxMz = 0; var selectedCharges = GetSelectedCharges(); var selectedMasses = GetSelectedMasses(); for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge++) { if (selectedCharges.Count > 0 && !selectedCharges.Contains(charge)) { continue; } for (int iMass = 0; iMass < PeptideAnalysis.GetMassCount(); iMass++) { if (selectedMasses.Count > 0 && !selectedMasses.Contains(iMass)) { continue; } var mzRange = PeptideAnalysis.GetMzs()[charge][iMass]; minMz = Math.Min(minMz, mzRange.Min); maxMz = Math.Max(maxMz, mzRange.Max); } } if (minMz <= maxMz) { spectrumForm.Zoom(minMz - 1, maxMz + 1); } }