public Calculator(int y, Demonstraror d) { NotActive = false; Random rand = new Random(); Number = rand.Next(0, 35); rest = y; Demonstrator = d; CalculatorEvent += new CalculatorEventHandler(Demonstrator.Show); }
private void button5_Click(object sender, EventArgs e) { try { G.bit = new Bitmap(pictureBox1.Width, pictureBox1.Height); G.graph = Graphics.FromImage(G.bit); int R = Int32.Parse(textBox1.Text); int time = Int32.Parse(textBox2.Text); int X = Int32.Parse(textBox3.Text); dem = new Demonstraror(Show1, Shoot1, time, R, X); calc = new Calculator(time, dem); dem.Calculator = calc; HatchBrush gr = new HatchBrush(HatchStyle.BackwardDiagonal, Color.DimGray, Color.Gray); int Y0 = pictureBox1.Height / 2; int X0 = pictureBox1.Width / 2; Rectangle p1 = new Rectangle(X0 - 2 * R, Y0, 2 * R, 2 * R); Rectangle p2 = new Rectangle(X0, Y0 - 2 * R, 2 * R, 2 * R); G.graph.FillPie(gr, p1, -45, -180); G.graph.FillPie(gr, p2, -45, 180); G.graph.DrawEllipse(new Pen(Color.DimGray), p1); G.graph.DrawEllipse(new Pen(Color.DimGray), p2); G.graph.DrawLine(new Pen(Color.Black), new Point(X0 - 2 * R, Y0 + 2 * R), new Point(X0 + 2 * R, Y0 - 2 * R)); G.graph.DrawLine(new Pen(Color.Black), new Point(X0, Y0 * 2), new Point(X0, 0)); G.graph.DrawLine(new Pen(Color.Black), new Point(X0 - 6, 6), new Point(X0, 0)); G.graph.DrawLine(new Pen(Color.Black), new Point(X0 + 6, 6), new Point(X0, 0)); G.graph.DrawLine(new Pen(Color.Black), new Point(2 * X0, Y0), new Point(0, Y0)); G.graph.DrawLine(new Pen(Color.Black), new Point(2 * X0, Y0), new Point(2 * X0 - 6, Y0 - 6)); G.graph.DrawLine(new Pen(Color.Black), new Point(2 * X0, Y0), new Point(2 * X0 - 6, Y0 + 6)); G.edial = new Bitmap(G.bit); textBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; button1.Enabled = true; button5.Enabled = false; } catch (FormatException x) { MessageBox.Show(x.Message); } catch (ArgumentException y) { MessageBox.Show(y.Message); } }