Programare
namespace Oop_instr_b_01 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public System.Drawing.Graphics desen; System.Drawing.SolidBrush culoare1; public bit bit1, bit2; bool val_b = false; int mod=4; // 1-Stanga, 2-Dreapta, 3-Avarie, 4 Oprire int count = 0; private void Form1_Load(object sender, EventArgs e) { desen = this.CreateGraphics(); culoare1 = new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen); bit1 = new bit(desen, 220, 50, 26, 3, culoare1); bit2 = new bit(desen, 270, 50, 26, 4, culoare1); } private void timer1_Tick(object sender, EventArgs e) { val_b = !val_b; if (mod == 1) { bit1.setval(val_b); bit2.setval(false); count++; } if (mod == 2) { bit1.setval(false); bit2.setval(val_b); count++; } if (mod == 3) { bit1.setval(val_b); bit2.setval(val_b); count++; } if (mod == 4) { bit1.setval(false); bit2.setval(false); count = 0; } if (count > 10) { mod = 4; count = 0; } } private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == (char)Keys.S) { mod = 1; } if (e.KeyValue == (char)Keys.D) { mod = 2; } if (e.KeyValue == (char)Keys.A) { mod = 3; } if (e.KeyValue == (char)Keys.O) { mod = 4; } } } public class bit... }