Make your own free website on Tripod.com
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 :PrintableForm
{
public new static void Main()
{
Application.Run(new Form1());
}

/// <summary>
/// Required designer variable.
/// </summary>


public Form1()
{
Text="CurVa SeNoiDaL";
}


protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
PointF[] aptf= new PointF[cx];
for(int i=0;i<cx;i++)
{
aptf[i].X=i;
aptf[i].Y=cy/2*(1-(float)Math.Sin(i*2*Math.PI/(cx-1)));
}
grfx.DrawLines(new Pen(clr),aptf);
}

}
}

public class PrintableForm:Form
{
public PrintableForm()
{
Text="fOrMuLaRiO ImPrIMiBLe";
BackColor=SystemColors.Window;
ForeColor=SystemColors.WindowText;
ResizeRedraw=true;
}
protected override void OnPaint(PaintEventArgs e)
{
DoPage(e.Graphics, ForeColor,ClientSize.Width,ClientSize.Height);
}
protected override void OnClick(EventArgs e)
{
PrintDocument prndoc=new PrintDocument();
prndoc.DocumentName=Text;
//prndoc.PrintPage+=new PrintPageEventHandler(PrintDocumentOnPrintPage);
prndoc.Print();
}
void PrintDocumentOnPaintPage(object obj,PrintPageEventArgs ppea)
{
Graphics grfx=ppea.Graphics;
SizeF sizef=grfx.VisibleClipBounds.Size;
DoPage(grfx,Color.Black,(int)sizef.Width,(int)sizef.Height);
}
protected virtual void DoPage(Graphics grfx,Color clr,int cx,int cy)
{
Pen pen=new Pen(clr);
grfx.DrawLine(pen,0,0,cx-1,cy-1);
grfx.DrawLine(pen,cx-1,0,0,cy-1);
}
}

En este codigo se definen todas las funciones necesarias para que se realice el trazado de una grafica senoidal.