Hago algo mal. En esta captura se muestra unao Panel, que son 8 en total y debe cambiar de color de rojo oscuro o normal dependiendo de como muesves el trackBar.
Verr zoom.
Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _74xx595_Vumetro_01_Net5._0
{
public partial class Form1 : Form
{
int valorADC = 1000;
public Form1()
{
InitializeComponent();
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
// Variar valor con el tarackBar.
valorADC = int.Parse("" + trackBar1.Value);
this.Text = valorADC.ToString();
switch (valorADC)
{
case 1000:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.Red;
panel4.BackColor = Color.Red;
panel5.BackColor = Color.Red;
panel6.BackColor = Color.Red;
panel7.BackColor = Color.Red;
panel8.BackColor = Color.Red;
break;
case 900:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.Red;
panel4.BackColor = Color.Red;
panel5.BackColor = Color.Red;
panel6.BackColor = Color.Red;
panel7.BackColor = Color.Red;
panel8.BackColor = Color.DarkRed;
break;
case 800:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.Red;
panel4.BackColor = Color.Red;
panel5.BackColor = Color.Red;
panel6.BackColor = Color.Red;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
case 700:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.Red;
panel4.BackColor = Color.Red;
panel5.BackColor = Color.Red;
panel6.BackColor = Color.DarkRed;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
case 600:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.Red;
panel4.BackColor = Color.Red;
panel5.BackColor = Color.DarkRed;
panel6.BackColor = Color.DarkRed;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
case 500:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.Red;
panel4.BackColor = Color.DarkRed;
panel5.BackColor = Color.DarkRed;
panel6.BackColor = Color.DarkRed;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
case 400:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.Red;
panel3.BackColor = Color.DarkRed;
panel4.BackColor = Color.DarkRed;
panel5.BackColor = Color.DarkRed;
panel6.BackColor = Color.DarkRed;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
case 300:
panel1.BackColor = Color.Red;
panel2.BackColor = Color.DarkRed;
panel3.BackColor = Color.DarkRed;
panel4.BackColor = Color.DarkRed;
panel5.BackColor = Color.DarkRed;
panel6.BackColor = Color.DarkRed;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
case 200:
panel1.BackColor = Color.DarkRed;
panel2.BackColor = Color.DarkRed;
panel3.BackColor = Color.DarkRed;
panel4.BackColor = Color.DarkRed;
panel5.BackColor = Color.DarkRed;
panel6.BackColor = Color.DarkRed;
panel7.BackColor = Color.DarkRed;
panel8.BackColor = Color.DarkRed;
break;
default:
this.Text = "Fuera de rango.";
break;
}
}
}
}
¿Alguna idea?
Saludos.