Ejemplo n.º 1
0
        private void Button_draw_3D_Click(object sender, EventArgs e)
        {
            string exp = textBox_exp_3D.Text;

            if (exp == "")
            {
                MessageBox.Show("请输入表达式。");
                return;
            }
            try
            {
                Function.Function func = new Function.Function(exp);
                Caculate3D = func.GetValue;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            if (MaxX_3D <= MinX_3D || MaxY_3D <= MinY_3D)
            {
                MessageBox.Show("定义域输入不合法。");
                return;
            }
            Bitmap bitmap = new Bitmap(pictureBox_3D.Width, pictureBox_3D.Height);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                painter3D = new Painter3D(pictureBox_3D, g, pen_3D, Caculate3D, MinX_3D, MaxX_3D, MinY_3D, MaxY_3D, rate);
                try
                {
                    painter3D.Draw();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                pictureBox_3D.Image = bitmap;
            }
        }
Ejemplo n.º 2
0
        private void Button_draw_Click(object sender, EventArgs e)
        {
            //double minX, minY, maxX, maxY;
            //try
            //{
            //    minX = double.Parse(textBox_minX.Text);
            //    maxX = double.Parse(textBox_maxX.Text);
            //    minY = double.Parse(textBox_minY.Text);
            //    maxY = double.Parse(textBox_maxY.Text);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //    return;
            //}
            if (maxX <= minX || maxY <= minY)
            {
                MessageBox.Show("数值输入不合法。");
                return;
            }
            //DrawFunction();
            Bitmap    bitmap  = new Bitmap(pictureBox.Width, pictureBox.Height);
            Graphics  g       = Graphics.FromImage(bitmap);
            Painter3D painter = new Painter3D(pictureBox, g, mypen, Caculate, minX, maxX, minY, maxY, rate);

            try
            {
                painter.Draw();
                pictureBox.Image = bitmap;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                g.Dispose();
            }
        }