public static bool AnalyzeFrequency(double frequency, out FrequencySource source, out Operator sourceOperator) { foreach (FrequencySource checkedSource in frequencySources) { if (frequency > checkedSource.minFreq && frequency <= checkedSource.maxFreq) { source = checkedSource; sourceOperator = null; if (checkedSource.operators != null) { foreach (SourceOperator checkedOperator in checkedSource.operators) { if (frequency > checkedOperator.minFreq && frequency <= checkedOperator.maxFreq) { sourceOperator = checkedOperator.sourceOperator; break; } } } return(true); } } source = null; sourceOperator = null; return(false); }
private void AddPoint(Series serie, DataPointCollection points, string unit, string serieName, double power, double frequency, ref FrequencySource lastSource) { string legendText = serieName; FrequencySource source = null; Operator sourceOperator = null; if (power > 0.0) { if (unit != "V/m") { power = Math.Pow(power * 0.377, 0.5); } legendText += $"\nIntensité : {power.ToString("0.000 V/m")}"; if (frequency > 0.0) { legendText += $"\nFréquence : {frequency.ToString("0.0 Mhz")}"; if (FrequencyAnalyzer.AnalyzeFrequency(frequency, out source, out sourceOperator)) { legendText += $"\n{source.name}"; if (Program.settings.GraphicShowOperator && sourceOperator != null) { legendText += $" ({sourceOperator.name})"; } } } serie.LegendText = legendText; int ptIdx = points.AddY(power); if (source != null) { if (source != lastSource) { lastSource = source; if (lastLabelDistance > 5) { lastLabelDistance = 0; string label = " \n"; // fix background being too small label += source.name; if (Program.settings.GraphicShowOperator && sourceOperator != null) { label += $"\n ({ sourceOperator.name})"; } label += $"\n{frequency.ToString("0 Mhz")}"; label += "\n "; // fix background being too small points[ptIdx].Label = label; } } } else { if (lastLabelDistance > 10) { lastSource = null; } } } else { points.AddY(-10.0); } }