0% found this document useful (0 votes)
80 views

Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains the code for a .NET Windows Forms application. It defines event handler methods for various form controls like buttons and text boxes. The main method draws a sine graph on the form by calculating x and y coordinates and drawing lines between points. It also draws some shapes and text using the Graphics object.

Uploaded by

Andrei Botnari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains the code for a .NET Windows Forms application. It defines event handler methods for various form controls like buttons and text boxes. The main method draws a sine graph on the form by calculating x and y coordinates and drawing lines between points. It also draws some shapes and text using the Graphics object.

Uploaded by

Andrei Botnari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Ecuatie
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void label6_Click(object sender, EventArgs e)
{
}
private void Form2_Load(object sender, EventArgs e)
{

}
private void textBox6_TextChanged(object sender, EventArgs e)
{
}
private void textBox11_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
System.Drawing.Pen myPen;
PointF pp = new PointF();
pp.X = 200; pp.Y = 200;
myPen = new
System.Drawing.Pen(System.Drawing.Color.Empty);
if(textBox1.Text=="0")
myPen = new
System.Drawing.Pen(System.Drawing.Color.FromName("Control"));
if (textBox1.Text == "1") myPen = new
System.Drawing.Pen(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics =
this.CreateGraphics();
System.Drawing.Graphics formGraphics1 =
this.CreateGraphics();
double hx, xi, ai, bi, v;
int lx, rx, uy, ly, nvalx, npx, npy, i, j, k, n, m, xx1,
yy1, xx2, yy2; string s, s1;
double yma, ymi, fv, upx, upy, mx;
ai = Convert.ToDouble(Ai.Text); bi =
Convert.ToDouble(Bi.Text);
lx = Convert.ToInt32(LeftX.Text); rx =
Convert.ToInt32(RightX.Text);
uy = Convert.ToInt32(UpperY.Text); ly =
Convert.ToInt32(LowerY.Text);
npx = rx - lx; npy = ly - uy; nvalx =
Convert.ToInt32(Nvalx.Text);
s = ""; s1 = ""; s = FFun.Text; s.Replace(" ", ""); k =
s.IndexOf("(");
s1 = s.Substring(1, k - 1); FFunR.Text = s1;
hx = (bi - ai) / nvalx; mx = Convert.ToDouble(mmx.Text);
yma = 0; ymi = 0;
for (i = 0; i < nvalx; i++)
{
v = Convert.ToDouble(i); xi = ai + (v - 1) * hx; fv =
Math.Sin(mx * xi);
if (yma < fv) yma = fv; if (ymi > fv) ymi = fv;
}
Ymin.Text = ymi.ToString(); Ymax.Text = yma.ToString();

upx = npx / (bi - ai); upy = npy / (yma - ymi);


for (i = 0; i < nvalx; i++)
{
v = Convert.ToDouble(i); xi = ai + (v - 1) * hx;
xx1 = Convert.ToInt32((lx + (v - 1) * hx * upx));
fv = Math.Sin(mx * xi);
yy1 = Convert.ToInt32(uy + (yma - fv) * upy);
v = Convert.ToDouble(i); xi = ai + (v) * hx;
xx2 = Convert.ToInt32((lx + (v) * hx * upx));
fv = Math.Sin(mx * xi);
yy2 = Convert.ToInt32(uy + (yma - fv) * upy);
formGraphics.DrawLine(myPen, xx1, yy1, xx2, yy2);
//formGraphics.Dispose();
}
string cc = "Red";
System.Drawing.SolidBrush myBrush,myBrush1,myBrush2;
myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
myBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
myBrush2 = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
myBrush = new System.Drawing.SolidBrush(Color.FromName(cc));
//Font ff=new System.Drawing.Font("Gill Sans Ultra Bold
Condensed", 20.0F);
Size siz=new Size(50,50);
Rectangle rect=new Rectangle(100,300,100,30);
Rectangle rect1=new Rectangle(200,300,30,80);
Rectangle rect2=new Rectangle(230,300,30,20);
Font ff=new System.Drawing.Font("Gill Sans Ultra Bold Condensed",
20.0F);
string rs = "Nicu nu este un student";
myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
formGraphics.DrawString(rs,ff,myBrush,pp);
formGraphics.DrawRectangle(myPen, 300F, 300F, 50, 50);
formGraphics.FillRectangle(myBrush2, rect2);
//formGraphics.DrawRectangle(myPen, rect1);
formGraphics.FillRectangle(myBrush1, rect1);
formGraphics1.FillPie(myBrush, rect, 0, 270);
formGraphics.Dispose();formGraphics1.Dispose();
myPen.Dispose();

}
private void button1_Click(object sender, EventArgs e)
{

}
private void button3_Click(object sender, EventArgs e)
{
}
}

You might also like