Form1 × Function: 000 Draw 000
simple utitly curve
i have this code
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApp11
{
public partial class Form1 : Form
{
private PictureBox displayArea;
private TextBox functionInput;
private Button drawButton;
private Label functionLabel;
public Form1()
{
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";
this.drawButton.Click += new System.EventHandler(this.DrawButton_Click);
//
// 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:";
//
// Form1
//
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 = "Form1";
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()
{
try
{
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++)
{
double yValue = Math.Sin(x * 0.05); // Example function (sinusoidal)
int y = (int)(100 * yValue);
g.DrawRectangle(pen, x, this.displayArea.Height / 2 - y, 1, 1);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error drawing function: " + ex.Message);
}
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
i have error cs1061
i have error cs0121
i have error cs0111
the image is the design
Unlock instant AI solutions
Tap the button
to generate a solution