private void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (listView.SelectedItems.Count > 1) { List <string> dataSourceList = new List <string>(); foreach (ListViewItem item in listView.SelectedItems) { if (item.SubItems[1].Text != "File Folder") { dataSourceList.Add(String.Format("\"{0}\"", item.SubItems[0].Text)); } } sourcePathTextBox.Text = String.Join(" ", dataSourceList.ToArray()); ticGraphControl.GraphPane.GraphObjList.Clear(); ticGraphControl.GraphPane.CurveList.Clear(); ticGraphControl.Visible = false; } else if (listView.SelectedItems.Count > 0) { sourcePathTextBox.Text = listView.SelectedItems[0].SubItems[0].Text; ticGraphControl.GraphPane.GraphObjList.Clear(); ticGraphControl.GraphPane.CurveList.Clear(); string sourcePath = Path.Combine(CurrentDirectory, sourcePathTextBox.Text); string sourceType = getSourceType(sourcePath); if (!String.IsNullOrEmpty(sourceType) && sourceType != "File Folder") { using (MSDataFile msData = new MSDataFile(sourcePath)) using (ChromatogramList cl = msData.run.chromatogramList) { if (cl != null && !cl.empty() && cl.find("TIC") != cl.size()) { ticGraphControl.Visible = true; pwiz.CLI.msdata.Chromatogram tic = cl.chromatogram(cl.find("TIC"), true); Map <double, double> sortedFullPointList = new Map <double, double>(); IList <double> timeList = tic.binaryDataArrays[0].data; IList <double> intensityList = tic.binaryDataArrays[1].data; int arrayLength = timeList.Count; for (int i = 0; i < arrayLength; ++i) { sortedFullPointList[timeList[i]] = intensityList[i]; } ZedGraph.PointPairList points = new ZedGraph.PointPairList( new List <double>(sortedFullPointList.Keys).ToArray(), new List <double>(sortedFullPointList.Values).ToArray()); ZedGraph.LineItem item = ticGraphControl.GraphPane.AddCurve("TIC", points, Color.Black, ZedGraph.SymbolType.None); item.Line.IsAntiAlias = true; ticGraphControl.AxisChange(); ticGraphControl.Refresh(); } else { ticGraphControl.Visible = false; } } } else { ticGraphControl.Visible = false; } } else { sourcePathTextBox.Text = ""; } }
private void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { string sourcePath = null; string sourceType = null; int runIndex = 0; if (listView.SelectedItems.Count > 0) { List <string> dataSourceList = new List <string>(); foreach (ListViewItem item in listView.SelectedItems) { var sourceInfo = item.Tag as SourceInfo; if (sourceInfo != null) { dataSourceList.Add(sourceInfo.path.ToString()); sourcePath = sourceInfo.path.Filepath; sourceType = sourceInfo.type; runIndex = sourceInfo.path.RunIndex; } else { dataSourceList.Add(item.SubItems[0].Text); sourcePath = Path.Combine(CurrentDirectory, sourcePathTextBox.Text); sourceType = getSourceType(sourcePath); } } sourcePathTextBox.Text = $"\"{String.Join("\" \"", dataSourceList.ToArray())}\""; } ticGraphControl.GraphPane.GraphObjList.Clear(); ticGraphControl.GraphPane.CurveList.Clear(); if (listView.SelectedItems.Count != 1) { ticGraphControl.Visible = false; return; } if (!String.IsNullOrEmpty(sourceType) && sourceType != "File Folder") { using (MSData msd = new MSData()) { ReaderList.FullReaderList.read(sourcePath, msd, runIndex, SpectrumSource.GetReaderConfig()); using (ChromatogramList cl = msd.run.chromatogramList) { if (cl != null && !cl.empty() && cl.find("TIC") != cl.size()) { ticGraphControl.Visible = true; pwiz.CLI.msdata.Chromatogram tic = cl.chromatogram(cl.find("TIC"), true); Map <double, double> sortedFullPointList = new Map <double, double>(); IList <double> timeList = tic.binaryDataArrays[0].data; IList <double> intensityList = tic.binaryDataArrays[1].data; int arrayLength = timeList.Count; for (int i = 0; i < arrayLength; ++i) { sortedFullPointList[timeList[i]] = intensityList[i]; } ZedGraph.PointPairList points = new ZedGraph.PointPairList( new List <double>(sortedFullPointList.Keys).ToArray(), new List <double>(sortedFullPointList.Values).ToArray()); ZedGraph.LineItem item = ticGraphControl.GraphPane.AddCurve("TIC", points, Color.Black, ZedGraph.SymbolType.None); item.Line.IsAntiAlias = true; ticGraphControl.AxisChange(); ticGraphControl.Refresh(); } else { ticGraphControl.Visible = false; } } } } else { ticGraphControl.Visible = false; } }