Hi I wonder if someone can help. I have managed to create a volume meter and am using the pipe "|" character for the visual display. I am able to change the color based on the volume Peak level and that works fine, but all the characters font colors change. What I am after however is for the original colors to remain. So that the string of pipes show Green, Yellow, Orange and then Red. Here is my code... So the question is how do I retain the original font colors, but change the new font colors as the volume starts to peak. If that Makes any sense. Many Thanks.
public void audiometering()
{
// start timer and select the volume value
vmt.Start();
MMDevice defaultDevice = devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
var volume = defaultDevice.AudioMeterInformation.MasterPeakValue;
var scale = (int)Math.Floor(volume * 20);
vUMonitorToolStripMenuItem.Text = volume.ToString();
// calculate scale of volume and display as pipes
var sb = new StringBuilder();
sb.Append('|', scale);
sb.Append(' ', 20 - scale);
vUMonitorToolStripMenuItem.Font = new Font(vUMonitorToolStripMenuItem.Font, FontStyle.Bold);
if ((scale <= 5))
{
vUMonitorToolStripMenuItem.ForeColor = Color.Green;
}
if ((scale >= 5 && scale <= 10))
{
vUMonitorToolStripMenuItem.ForeColor = Color.Yellow;
}
if ((scale >= 10 && scale <= 15))
{
vUMonitorToolStripMenuItem.ForeColor = Color.Orange;
}
if ((scale >= 15))
{
vUMonitorToolStripMenuItem.ForeColor = Color.Red;
}
vUMonitorToolStripMenuItem.Text = sb.ToString();
}