void DrawLevel(float dB, MarkersValues Marker, Graphics g, CGraph Graph) { Pen mypenArrow = new Pen(Color.Black, 1.0f); Pen mypenHline = new Pen(Color.Black, 1.0f); mypenHline.DashStyle = DashStyle.Dash; Pen mypenVline = new Pen(Color.Black, LineWidth); mypenVline.DashStyle = DashStyle.DashDot; System.Drawing.StringFormat VerticalTextDrawFormat = new System.Drawing.StringFormat(); VerticalTextDrawFormat.FormatFlags = StringFormatFlags.DirectionVertical; System.Drawing.Font SampleFont = new Font("Verdana", Graph.BitmapWhereDraw.Width / 120.0f); String ndB = ((int)dB).ToString() + "dB"; bool bCliped = false; // bandpass if (Marker.HighFreq > 0 && Marker.LowFreq > 0) { // bandpass PointF HCoords1 = Graph.GetCoords(Marker.LowFreq, fMaxLeveldB + dB, ref bCliped); if (!bCliped) { mypenHline.CustomStartCap = new AdjustableArrowCap(5.0f, 5.0f); } if (!bCliped) { PointF VCoords1 = new PointF(HCoords1.X, Graph.UpBorder); PointF VCoords2 = new PointF(HCoords1.X, Graph.BitmapWhereDraw.Height - Graph.LowBorder); g.DrawLine(mypenVline, VCoords1, VCoords2); PointF CoordVCenter = new PointF(VCoords1.X, 0.5f * (VCoords1.Y + VCoords2.Y)); g.DrawString(Utility.GetFrequencyStringAtBest(Marker.LowFreq), SampleFont, Brushes.Black, CoordVCenter, VerticalTextDrawFormat); } PointF HCoords2 = Graph.GetCoords(Marker.HighFreq, fMaxLeveldB + dB, ref bCliped); if (!bCliped) { mypenHline.CustomEndCap = new AdjustableArrowCap(5.0f, 5.0f); } if (!bCliped) { PointF VCoords1 = new PointF(HCoords2.X, Graph.UpBorder); PointF VCoords2 = new PointF(HCoords2.X, Graph.BitmapWhereDraw.Height - Graph.LowBorder); g.DrawLine(mypenVline, VCoords1, VCoords2); PointF CoordVCenter = new PointF(VCoords1.X, 0.5f * (VCoords1.Y + VCoords2.Y)); g.DrawString(Utility.GetFrequencyStringAtBest(Marker.HighFreq), SampleFont, Brushes.Black, CoordVCenter, VerticalTextDrawFormat); } g.DrawLine(mypenHline, HCoords1, HCoords2); PointF CoordCenter = new PointF(0.5f * (HCoords1.X + HCoords2.X), HCoords1.Y); g.DrawString(" " + ndB + " (" + Utility.GetFrequencyStringAtBest(Marker.BandPass) + ")", SampleFont, Brushes.Black, CoordCenter); } else { if (Marker.BandPass == 0) { // Hline ( min or max) PointF Coords0 = Graph.GetCoords(this.nSpectrumLowFrequency, fMaxLeveldB + dB, ref bCliped); PointF Coords1 = Graph.GetCoords(this.nSpectrumHighFrequency, fMaxLeveldB + dB, ref bCliped); g.DrawLine(mypenHline, Coords0, Coords1); } else { if (Marker.HighFreq > 0) { // low pass PointF Coords0 = Graph.GetCoords(this.nSpectrumLowFrequency, fMaxLeveldB + dB, ref bCliped); PointF Coords1 = Graph.GetCoords(Marker.HighFreq, fMaxLeveldB + dB, ref bCliped); PointF Coords2 = new PointF(Coords1.X, Graph.BitmapWhereDraw.Height - Graph.LowBorder); g.DrawLine(mypenHline, Coords0, Coords1); g.DrawLine(mypenVline, Coords1, Coords2); PointF CoordHCenter = new PointF(0.5f * (Coords0.X + Coords1.X), Coords0.Y); PointF CoordVCenter = new PointF(Coords1.X, 0.5f * (Coords1.Y + Coords2.Y)); g.DrawString(Utility.GetFrequencyStringAtBest(Marker.HighFreq), SampleFont, Brushes.Black, CoordVCenter, VerticalTextDrawFormat); g.DrawString(ndB, SampleFont, Brushes.Black, CoordHCenter); } if (Marker.LowFreq > 0) { PointF Coords0 = Graph.GetCoords(this.nSpectrumHighFrequency, fMaxLeveldB + dB, ref bCliped); PointF Coords1 = Graph.GetCoords(Marker.LowFreq, fMaxLeveldB + dB, ref bCliped); PointF Coords2 = new PointF(Coords1.X, Graph.BitmapWhereDraw.Height - Graph.LowBorder); g.DrawLine(mypenHline, Coords0, Coords1); g.DrawLine(mypenVline, Coords1, Coords2); PointF CoordCenter = new PointF(0.5f * (Coords0.X + Coords1.X), Coords0.Y); PointF CoordVCenter = new PointF(Coords1.X, 0.5f * (Coords1.Y + Coords2.Y)); g.DrawString(Utility.GetFrequencyStringAtBest(Marker.LowFreq), SampleFont, Brushes.Black, CoordVCenter, VerticalTextDrawFormat); g.DrawString(ndB, SampleFont, Brushes.Black, CoordCenter); } } } }