示例#1
0
        private void MyThread()
        {
            BattleField Battle = BattleField.getBat();

            Battle.DelR();
            int i = Battle.DoMany(ArmyA, ArmyB);

            if (i == 1 || i == 2)
            {
                if (i == 1)
                {
                    string s = Battle.WhoWin() + " выиграли!";
                    Battle.NotifyObserverF(s);

                    MessageBox.Show(s, "Win!", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Ничья.", "GameOver!", MessageBoxButtons.OK);
                    Battle.NotifyObserverF("Ничья.");
                }
                Restart.Invoke(new Action(() => Restart.Enabled     = true));
                UnDo.Invoke(new Action(() => UnDo.Enabled           = false));
                ReDo.Invoke(new Action(() => ReDo.Enabled           = false));
                OneStep.Invoke(new Action(() => OneStep.Enabled     = false));
                Start.Invoke(new Action(() => Start.Enabled         = false));
                Pause.Invoke(new Action(() => Pause.Enabled         = false));
                groupBox2.Invoke(new Action(() => groupBox2.Enabled = true));

                groupBox1.Invoke(new Action(() => groupBox1.Enabled = true));
            }
        }
示例#2
0
        public PrettyForm()
        {
            InitializeComponent();

            KeyPreview = true;

            buttonExit.Click  += (s, e) => Close();
            buttonRun.Click   += (s, e) => AutoStart?.Invoke(s, e);
            buttonStop.Click  += (s, e) => AutoStop?.Invoke(s, e);
            buttonReset.Click += (s, e) => ResetAll?.Invoke(s, e);
            buttonStep.Click  += (s, e) => OneStep?.Invoke(s, e);
        }
示例#3
0
        private void button3_Click(object sender, EventArgs e)
        {
            groupBox2.Invoke(new Action(() => groupBox2.Enabled = false));

            groupBox1.Invoke(new Action(() => groupBox1.Enabled = false));
            button1.Invoke(new Action(() => button1.Enabled     = false));
            button1.Invoke(new Action(() => button1.Enabled     = false));
            Restart.Invoke(new Action(() => Restart.Enabled     = false));
            UnDo.Invoke(new Action(() => UnDo.Enabled           = false));
            ReDo.Invoke(new Action(() => ReDo.Enabled           = false));
            OneStep.Invoke(new Action(() => OneStep.Enabled     = false));
            Start.Invoke(new Action(() => Start.Enabled         = false));
            Pause.Invoke(new Action(() => Pause.Enabled         = true));
            System.Threading.Thread MY = new System.Threading.Thread(MyThread);
            MY.Start();
        }