Пример #1
0
        /// <summary>
        /// Обработчик нажатия кнопки "Вероятностое заполнение"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_random_Click(object sender, EventArgs e)
        {
            RandomForm rf = new RandomForm();

            //При закрытии формы передается значение рандома
            rf.FormClosing += (sender1, e1) =>
            {
                if (rf.GetRandVal() != -1)                              //if nothing_changed;
                {
                    CellAutomaton.DensityFillMatrix(Cells, rf.GetRandVal());
                    paint(Cells);
                }
            };

            rf.ShowDialog();
        }
Пример #2
0
        /// <summary>
        /// Загрузка формы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            step = new CA_Step(CellAutomaton.CellularAutomaton);


            glControl1.Size = new Size(n * (squareDim + 1), hScrollBar1.Location.Y - glControl1.Location.Y);   //617 is magic number | n * (squareDim + 1)
            cameraChanged();

            //Фон
            // panel1.BackColor = Color.Black;

            //Заполняем матрицу
            CellAutomaton.FillMatrix(Cells);
            memarr = (byte[, ])Cells.Clone();

            //Генерация поколений выключена
            GenerationTimer.Enabled = false;

            //Конвеевская жизнь по умолчанию. S/B 23/3
            rulesChListBox.SetItemChecked(2, true);
            rulesChListBox.SetItemChecked(3, true);
            rulesChListBox.SetItemChecked(12, true);

            //Правила
            GetArrayOfRules();

            ToolStrip_timebtn.Text = DELAY + GenerationTimer.Interval;

            cellC = Color.FromArgb(0, 255, 0); //Зеленый цвет
            backC = Color.Black;

            hScrollBar1.Width  = glControl1.Width;
            vScrollBar1.Height = glControl1.Height;
            ScrollBarsInitialize();

            thorChB.Checked = true;

            toolStripLabel_steps.Text = "Число шагов: " + 0;
            toolStripLabel_X.Text     = "X: " + 0;
            toolStripLabel_Y.Text     = "Y: " + 0;

            FullSize();
        }
Пример #3
0
 /// <summary>
 /// Обработчик нажатия кнопки "Случайное заполнение"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnFillMatrix_Click(object sender, EventArgs e)
 {
     CellAutomaton.FillMatrix(Cells);
     paint(Cells);
 }