private void timer1_Tick(object sender, EventArgs e) { if (checkBox1.Checked) { Random rnd = new Random(); int l = rnd.Next(7); int h = rnd.Next(6); int v = 7 * h + l; byte r = (byte)(rnd.Next(256) * trackBar1.Value / 100); byte g = (byte)(rnd.Next(256) * trackBar1.Value / 100); byte b = (byte)(rnd.Next(256) * trackBar1.Value / 100); OpenDMX.setDmxValue(v * 6 + 1 + 0, r); OpenDMX.setDmxValue(v * 6 + 1 + 1, g); OpenDMX.setDmxValue(v * 6 + 1 + 2, b); OpenDMX.writeData(); buttons[l, h].BackColor = Color.FromArgb(r, g, b); //updateButtons(); } else if (checkBox2.Checked || checkBox3.Checked || checkBox4.Checked) { List <byte[, ]> let = null; if (checkBox2.Checked) { let = connect4sls; } else if (checkBox3.Checked) { let = springfling2018; } else if (checkBox4.Checked) { let = springfling2018connect; } for (int x = 0; x < 7; x++) { for (int y = 0; y < 6; y++) { byte[,] a = let[(letterstate / 8) % let.Count]; Color c = Color.Black; if (a[y, x] == 0 || letterstate % 8 == 0) { c = ncolor; } else { c = p1color; } this.buttons[x, y].BackColor = c; OpenDMX.setDmxValue(address[x, y] + 0, (byte)(c.R * trackBar1.Value / 100)); OpenDMX.setDmxValue(address[x, y] + 1, (byte)(c.G * trackBar1.Value / 100)); OpenDMX.setDmxValue(address[x, y] + 2, (byte)(c.B * trackBar1.Value / 100)); } } OpenDMX.writeData(); letterstate++; //updateButtons(); } else { updateButtons(); } }
void updateButtons() { //Player color buttons P1ColorButton.BackColor = p1color; P2ColorButton.BackColor = p2color; NeutralColorButton.BackColor = ncolor; //Turn Color tc = Color.Black; if (turn == PosState.Player1) { turnButton.Text = "Player 1"; tc = p1color; } else if (turn == PosState.Player2) { turnButton.Text = "Player 2"; tc = p2color; } turnButton.BackColor = tc; OpenDMX.setDmxValue(253, (byte)(tc.R * trackBar1.Value / 100)); OpenDMX.setDmxValue(254, (byte)(tc.G * trackBar1.Value / 100)); OpenDMX.setDmxValue(255, (byte)(tc.B * trackBar1.Value / 100)); OpenDMX.setDmxValue(260, 0); if (win) { OpenDMX.setDmxValue(253, 0); OpenDMX.setDmxValue(254, 0); OpenDMX.setDmxValue(255, 0); } //Buttons Random rnd = new Random();//random for twinkling for (int x = 0; x < 7; x++) { for (int y = 0; y < 6; y++) { Color c = Color.Black; switch (state[x, y]) { case PosState.Neutral: c = ncolor; if (win) //Twinkle if you win { byte v = (byte)(150 - rnd.Next(100)); c = Color.FromArgb(v, v, v); } break; case PosState.Player1: c = p1color; break; case PosState.Player2: c = p2color; break; } this.buttons[x, y].BackColor = c; OpenDMX.setDmxValue(address[x, y] + 0, (byte)(c.R * trackBar1.Value / 100)); OpenDMX.setDmxValue(address[x, y] + 1, (byte)(c.G * trackBar1.Value / 100)); OpenDMX.setDmxValue(address[x, y] + 2, (byte)(c.B * trackBar1.Value / 100)); //OpenDMX.setDmxValue(address[x, y] + 0, (byte)c.R ); //OpenDMX.setDmxValue(address[x, y] + 1, (byte)c.G ); //OpenDMX.setDmxValue(address[x, y] + 2, (byte)c.B); } } OpenDMX.writeData(); }