Пример #1
0
 void Clear() //Очистка полотна
 {
     graph.Clear(Color.White);
     picture.Image = bmp;
     isEmpty       = true;
     data          = null;
 }
Пример #2
0
 private void picture_MouseUp(object sender, MouseEventArgs e) //Переместить фрактал
 {
     if (start != null && !isEmpty)
     {
         Point end = new Point(Cursor.Position.X, Cursor.Position.Y);
         float dx  = end.x - start.x;
         float dy  = end.y - start.y;
         data = new FractalData
                    (data.Name, data.Depth, new Point(data.Center.x + dx, data.Center.y + dy));
         graph.Clear(Color.White);
         _Draw();
         start = null;
     }
 }
Пример #3
0
        void Draw()  //Отсрисовка фрактала
        {
            Clear(); //Сначала очищаем полотно
            string fractal_name = "";
            int    depth        = 0;
            bool   flag         = true;

            try
            {
                fractal_name = comboBox1.SelectedItem.ToString();
            }
            catch //Вылетает исключение если фрактал не выбран
            {
                MessageBox.Show("Выберите фрактал!", "Ошибка!");
                flag = false;
            }
            if (flag)
            {
                try
                {
                    int.TryParse(textBox1.Text, out depth);
                    if (depth < 1)
                    {
                        throw new Exception();
                    }
                }

                catch //Вылетает исключение если некорректно ввести глубину
                {
                    MessageBox.Show("Некорректный ввод глубины!", "Ошибка!");
                    flag = false;
                }
                if (flag)
                {
                    Point center = new Point(picture.Width / 2, picture.Height / 2);
                    data = new FractalData(fractal_name, depth, center);
                    _Draw();
                }
            }
        }