computer graphics  simple utility curvei make this code in c#.net but i have error and cant fix it in visual studioi need to fix code and i need to make it to draw curve the design is the picture    this is code  using System;using System.Drawing;using System.Windows.Forms; public class FunctionCurveForm : Form{    private PictureBox displayArea;    private TextBox functionInput;    private Button drawButton;    private Label functionLabel;     public FunctionCurveForm()    {        InitializeComponent();    }     private void InitializeComponent()    {            this.displayArea = new System.Windows.Forms.PictureBox();            this.functionInput = new System.Windows.Forms.TextBox();            this.drawButton = new System.Windows.Forms.Button();            this.functionLabel = new System.Windows.Forms.Label();            ((System.ComponentModel.ISupportInitialize)(this.displayArea)).BeginInit();            this.SuspendLayout();            //             // displayArea            //             this.displayArea.BackColor = System.Drawing.Color.White;            this.displayArea.Location = new System.Drawing.Point(10, 10);            this.displayArea.Name = "displayArea";            this.displayArea.Size = new System.Drawing.Size(400, 300);            this.displayArea.TabIndex = 0;            this.displayArea.TabStop = false;            //             // functionInput            //             this.functionInput.Location = new System.Drawing.Point(80, 320);            this.functionInput.Name = "functionInput";            this.functionInput.Size = new System.Drawing.Size(230, 22);            this.functionInput.TabIndex = 2;            //             // drawButton            //             this.drawButton.Location = new System.Drawing.Point(320, 320);            this.drawButton.Name = "drawButton";            this.drawButton.Size = new System.Drawing.Size(90, 22);            this.drawButton.TabIndex = 3;            this.drawButton.Text = "Draw";            //             // functionLabel            //             this.functionLabel.AutoSize = true;            this.functionLabel.Location = new System.Drawing.Point(10, 320);            this.functionLabel.Name = "functionLabel";            this.functionLabel.Size = new System.Drawing.Size(60, 16);            this.functionLabel.TabIndex = 1;            this.functionLabel.Text = "Function:";            //             // FunctionCurveForm            //             this.ClientSize = new System.Drawing.Size(430, 380);            this.Controls.Add(this.displayArea);            this.Controls.Add(this.functionLabel);            this.Controls.Add(this.functionInput);            this.Controls.Add(this.drawButton);            this.Name = "FunctionCurveForm";            this.Text = "Function Curve Drawer";            ((System.ComponentModel.ISupportInitialize)(this.displayArea)).EndInit();            this.ResumeLayout(false);            this.PerformLayout();     }     private void DrawButton_Click(object sender, EventArgs e)    {        DrawFunction();    }     private void DrawFunction()    {        using (Graphics g = this.displayArea.CreateGraphics())        {            g.Clear(Color.White);            Pen pen = new Pen(Color.Black);             for (int x = 0; x < this.displayArea.Width; x++)            {                int y = (int)(100 * Math.Sin(x * 0.05)); // Example function                g.DrawRectangle(pen, x, this.displayArea.Height / 2 - y, 1, 1);            }        }    }     [STAThread]    static void Main()    {        Application.EnableVisualStyles();        Application.SetCompatibleTextRenderingDefault(false);        Application.Run(new FunctionCurveForm());    }}

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter12: Event-driven Gui Programming, Multithreading, And Animation
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

computer graphics 

simple utility curve
i make this code in c#.net but i have error and cant fix it in visual studio

i need to fix code and i need to make it to draw curve 
the design is the picture 

 

this is code 

using System;
using System.Drawing;
using System.Windows.Forms;

public class FunctionCurveForm : Form
{
    private PictureBox displayArea;
    private TextBox functionInput;
    private Button drawButton;
    private Label functionLabel;

    public FunctionCurveForm()
    {
        InitializeComponent();
    }

    private void InitializeComponent()
    {
            this.displayArea = new System.Windows.Forms.PictureBox();
            this.functionInput = new System.Windows.Forms.TextBox();
            this.drawButton = new System.Windows.Forms.Button();
            this.functionLabel = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.displayArea)).BeginInit();
            this.SuspendLayout();
            // 
            // displayArea
            // 
            this.displayArea.BackColor = System.Drawing.Color.White;
            this.displayArea.Location = new System.Drawing.Point(10, 10);
            this.displayArea.Name = "displayArea";
            this.displayArea.Size = new System.Drawing.Size(400, 300);
            this.displayArea.TabIndex = 0;
            this.displayArea.TabStop = false;
            // 
            // functionInput
            // 
            this.functionInput.Location = new System.Drawing.Point(80, 320);
            this.functionInput.Name = "functionInput";
            this.functionInput.Size = new System.Drawing.Size(230, 22);
            this.functionInput.TabIndex = 2;
            // 
            // drawButton
            // 
            this.drawButton.Location = new System.Drawing.Point(320, 320);
            this.drawButton.Name = "drawButton";
            this.drawButton.Size = new System.Drawing.Size(90, 22);
            this.drawButton.TabIndex = 3;
            this.drawButton.Text = "Draw";
            // 
            // functionLabel
            // 
            this.functionLabel.AutoSize = true;
            this.functionLabel.Location = new System.Drawing.Point(10, 320);
            this.functionLabel.Name = "functionLabel";
            this.functionLabel.Size = new System.Drawing.Size(60, 16);
            this.functionLabel.TabIndex = 1;
            this.functionLabel.Text = "Function:";
            // 
            // FunctionCurveForm
            // 
            this.ClientSize = new System.Drawing.Size(430, 380);
            this.Controls.Add(this.displayArea);
            this.Controls.Add(this.functionLabel);
            this.Controls.Add(this.functionInput);
            this.Controls.Add(this.drawButton);
            this.Name = "FunctionCurveForm";
            this.Text = "Function Curve Drawer";
            ((System.ComponentModel.ISupportInitialize)(this.displayArea)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

    }

    private void DrawButton_Click(object sender, EventArgs e)
    {
        DrawFunction();
    }

    private void DrawFunction()
    {
        using (Graphics g = this.displayArea.CreateGraphics())
        {
            g.Clear(Color.White);
            Pen pen = new Pen(Color.Black);

            for (int x = 0; x < this.displayArea.Width; x++)
            {
                int y = (int)(100 * Math.Sin(x * 0.05)); // Example function
                g.DrawRectangle(pen, x, this.displayArea.Height / 2 - y, 1, 1);
            }
        }
    }

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new FunctionCurveForm());
    }
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT