各位大侠 谁能给我一个用c#编的画图函数程序  只要能画曲线就可以拉 大家帮忙啊

解决方案 »

  1.   

    写了个很简单的,楼主参考一下;
    public void DrawLine()
            {
                Graphics g = this.CreateGraphics();
                Pen redPen = new Pen (Color.Red );
                Point[] poins = new Point [] {new Point (0,0),new Point (50,50),new Point (200,150)}; //把点输进来就可以了
                g.DrawLines(redPen, poins);        }
      

  2.   

    感谢上面这个高手的函数 不过我想要个这样的
     public void DrawCurve(Pen pen,Point[] points)
    可以直接引用的 
    我还想就是编译一个函数可以确定画线的坐标 不是固定的 就是画图的那种画到哪里就是哪里
      

  3.   

    //成员
    Graphics g;
    int oldX = 0;
    int oldY = 0;//
    g = this.CreateGraphics();
    //在鼠标移动事件中
    private void MsMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
      g.DrawLine(new Pen(Color.Red), oldX, oldY, e.X, e.Y);
      oldX = e.X;
      oldY = e.Y;
    }
      

  4.   

    private void MsMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
      g.DrawLine(new Pen(Color.Red), oldX, oldY, e.X, e.Y);
      oldX = e.X;
      oldY = e.Y;
    }
    好象这个函数没有起作用啊
    不好意思啊 我是刚开始学习应用阶段 菜鸟一个 请大家多多指教 我直接将这个函数贴在代码里了 可是怎么没有起作用呢
      

  5.   

    不过我想要个这样的
     public void DrawCurve(Pen pen,Point[] points)
    可以直接引用的 
    ------------------------------------------------------------------
    那不是更简单?
    public void DrawCurve(Pen pen,Point[] points )
            {
                Graphics g = this.CreateGraphics();
                g.DrawLines(pen, poins);        }
      

  6.   

    //鼠标移动就是画线了。
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace DrawTest
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    //成员
    Graphics g;
    int oldX = 0;
    int oldY = 0; public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    g = this.CreateGraphics();
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Name = "Form1";
    this.Text = "Form1";
    this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MsMove); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } //在鼠标移动事件中
    private void MsMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    g.DrawLine(new Pen(Color.Red), oldX, oldY, e.X, e.Y);
    oldX = e.X;
    oldY = e.Y;
    } }
    }
      

  7.   

    //鼠标按下才开始画线的例子
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace DrawTest
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    //成员
    Graphics g;
    bool Drag=false;
    int oldX = 0;
    int oldY = 0; public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    g = this.CreateGraphics();
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Name = "Form1";
    this.Text = "Form1";
    this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MsDown);
    this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MsUp);
    this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MsMove); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } //在鼠标移动事件中
    private void MsMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if (Drag)
    {
    g.DrawLine(new Pen(Color.Red), oldX, oldY, e.X, e.Y);
    oldX = e.X;
    oldY = e.Y;
    }
    } private void MsDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    Drag = true;
    oldX=e.X;
    oldY=e.Y;
    } private void MsUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    Drag = false;
    } }
    }
      

  8.   

    建议使用矢量图形组件TCAD
    http://www.codeidea.com/cn/