private void seems_MdiChildActivate(object sender, EventArgs e) { ToolStrip1.Items.Remove(DummyScanNumberComboBoxHost); foreach (Form f in MdiChildren) { ToolStrip1.Items.Remove(((GraphForm)f).ScanNumberComboBoxHost); } if (CurrentGraphForm != null) { ToolStrip1.Items.Insert(ToolStrip1.Items.Count - 2, CurrentGraphForm.ScanNumberComboBoxHost); SeemsScan selectedScan = (SeemsScan)CurrentGraphForm.ScanNumberComboBox.SelectedItem; if (selectedScan != null && CurrentGraphForm.ScanNumberComboBox.Items.Count > 0) { setScanControls(true); } else { setScanControls(false); } } if (ActiveMdiChild == null) { ToolStrip1.Items.Insert(ToolStrip1.Items.Count - 2, DummyScanNumberComboBoxHost); DummyScanNumberComboBoxHost.Enabled = false; } }
public void setScanControls(bool enabled) { peakProcessingToolStripDropDownButton.Enabled = enabled; annotateToolStripDropDownButton.Enabled = enabled; if (CurrentGraphForm != null) { CurrentGraphForm.ScanNumberComboBox.Enabled = enabled; if (enabled == true) { SeemsScan selectedScan = (SeemsScan)CurrentGraphForm.ScanNumberComboBox.SelectedItem; if (selectedScan.Scan.IsCentroided) { CentroidMenuItem.Enabled = false; CentroidMenuItem.Checked = true; } else { CentroidMenuItem.Enabled = true; } if (selectedScan.IsMassSpectrum) { peakProcessingToolStripDropDownButton.Enabled = true; peptideFragmentationToolStripMenuItem.Enabled = true; peptideMassMappingToolStripMenuItem.Enabled = true; } else { peakProcessingToolStripDropDownButton.Enabled = false; peptideFragmentationToolStripMenuItem.Enabled = false; peptideMassMappingToolStripMenuItem.Enabled = false; } } } }
private void showData(int dataIndex, bool isOverlay) { SeemsScan scan = dataSource.CurrentScanHeaders[dataIndex]; ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; if (isOverlay && pane.CurveList.Count > overlayColors.Length) { MessageBox.Show("SeeMS only supports up to " + overlayColors.Length + " simultaneous overlays.", "Too many overlays", MessageBoxButtons.OK, MessageBoxIcon.Stop); } // set form title if (!isOverlay) { Text = String.Format("{0} - {1}", System.IO.Path.GetFileName(dataSource.CurrentFilepath), scan.Id); } else { Text += "," + scan.Id; } if (!isOverlay) { pane.CurveList.Clear(); } if (shownScan != null && scan.IsMassSpectrum != shownScan.IsMassSpectrum) { zedGraphControl1.RestoreScale(pane); zedGraphControl1.ZoomOutAll(pane); } bool isScaleAuto = !pane.IsZoomed; //pane.GraphObjList.Clear(); SeemsPointList pointList = scan.PointList; if (pointList.FullCount == 0) { // the header does not have the data points, assume it is a mass spectrum pane.YAxis.Title.Text = "Intensity"; pane.XAxis.Title.Text = "m/z"; bool doCentroid = SeemsMdiParent.CentroidMenuItem.Enabled && SeemsMdiParent.CentroidMenuItem.Checked; dataSource.InstrumentInterface.setCentroiding(doCentroid, doCentroid, SeemsMdiParent.UseVendorCentroidMenuItem.Checked); SeemsScan scanWithData = new SeemsScan(dataSource.InstrumentInterface.getScan(scan.Scan.ScanNumber)); pointList = scanWithData.PointList; int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; if (isScaleAuto) { pointList.SetScale(bins, pointList[0].X, pointList[pointList.Count - 1].X); } else { pointList.SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } if (doCentroid || scanWithData.Scan.IsCentroided) { ZedGraph.StickItem stick = pane.AddStick(scan.Id, pointList, Color.Gray); stick.Symbol.IsVisible = false; stick.Line.Width = 1; } else { pane.AddCurve(scan.Id, pointList, Color.Gray, ZedGraph.SymbolType.None); } } else { // the header has the data points, assume it is a chromatogram int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; if (isScaleAuto) { pointList.SetScale(bins, pointList[0].X, pointList[pointList.Count - 1].X); } else { pointList.SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } pane.YAxis.Title.Text = "Total Intensity"; pane.XAxis.Title.Text = "Retention Time (in seconds)"; pane.AddCurve(scan.Id, pointList, Color.Gray, ZedGraph.SymbolType.None); } pane.AxisChange(); if (isOverlay) { pane.Legend.IsVisible = true; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; for (int i = 0; i < pane.CurveList.Count; ++i) { pane.CurveList[i].Color = overlayColors[i]; } } else { pane.Legend.IsVisible = false; } SetDataLabelsVisible(true); shownScan = scan; zedGraphControl1.Refresh(); //zedGraphControl1.Focus(); }
//private decimal lastMaxPeakCountValue; //private string lastExtraOptionsText; private bool generateSpectrumSvg() { try { scanNumberChangedTimer.Stop(); Application.DoEvents(); if (scanNumberComboBox.Enabled == false) { return(false); } SeemsScan selectedScan = (SeemsScan)scanNumberComboBox.SelectedItem; if (selectedScan.Scan.IsCentroided) { SeemsMdiParent.CentroidMenuItem.Enabled = false; SeemsMdiParent.CentroidMenuItem.Checked = true; } else { SeemsMdiParent.CentroidMenuItem.Enabled = true; } ManagedScan curScan; SortedDictionary <double, string> peakLabels2 = new SortedDictionary <double, string>(); SortedDictionary <double, string> peakColors = new SortedDictionary <double, string>(); SortedDictionary <double, int> peakWidths = new SortedDictionary <double, int>(); if (selectedScan.Scan.ScanNumber > 0) { bool doCentroid = SeemsMdiParent.CentroidMenuItem.Enabled && SeemsMdiParent.CentroidMenuItem.Checked; instrumentInterface.setCentroiding(doCentroid, doCentroid, SeemsMdiParent.UseVendorCentroidMenuItem.Checked); curScan = instrumentInterface.getScan(selectedScan.Scan.ScanNumber); if (curScan == null) { throw new Exception("failed to get scan data for scan " + selectedScan.Scan.ScanNumber); } foreach (KeyValuePair <string, List <KeyValuePair <double, int> > > ionListItr in peakLabels) { foreach (KeyValuePair <double, int> ionMzChargePair in ionListItr.Value) { string[] labelNameIndexPair = ionListItr.Key.Split(" ".ToCharArray()); if (peakAnnotationSettings.ContainsKey(labelNameIndexPair[0])) { KeyValuePair <string, string> svgLabelColorPair = peakAnnotationSettings[labelNameIndexPair[0]]; if (ionMzChargePair.Value > 1) { peakLabels2[ionMzChargePair.Key] = String.Format("{0}{1} (+{2})", svgLabelColorPair.Key, labelNameIndexPair[1], ionMzChargePair.Value); } else { peakLabels2[ionMzChargePair.Key] = String.Format("{0}{1}", svgLabelColorPair.Key, labelNameIndexPair[1]); } peakColors[ionMzChargePair.Key] = svgLabelColorPair.Value; } else { peakLabels2[ionMzChargePair.Key] = ionListItr.Key; peakColors[ionMzChargePair.Key] = "blue"; } peakWidths[ionMzChargePair.Key] = 2; } } SeemsMdiParent.PeakProcessingButton.Enabled = true; SeemsMdiParent.AnnotateButton.Enabled = true; } else { curScan = selectedScan.Scan; SeemsMdiParent.PeakProcessingButton.Enabled = false; SeemsMdiParent.AnnotateButton.Enabled = false; } String tmpSvgFilename = Path.GetTempPath() + "seems.svg"; StreamWriter tmpSvgFile = new StreamWriter(tmpSvgFilename); tmpSvgFile.Write(curScan.writeToSvg(peakLabels2, peakColors, peakWidths)); tmpSvgFile.Close(); webBrowser1.Url = new Uri("file://" + tmpSvgFilename + navigatingQuery.ToString()); Process.GetCurrentProcess().Exited += new EventHandler(generateSpectrumSvg_cleanup); scanNumberChangedTimer.Stop(); webBrowser1.Focus(); //Application.DoEvents(); } catch (Exception ex) { string message = "SeeMS encountered an error generating the spectrum graphics (" + ex.Message + ")"; if (ex.InnerException != null) { message += "\n\nAdditional information: " + ex.InnerException.Message; } MessageBox.Show(message, "Error generating spectrum graphics", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0, false); return(false); } return(true); }