解决方案 »

  1.   

    原文代码在这儿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 wangshang
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            int a = 0;
            private void button1_Click(object sender, EventArgs e)
            {
                a = 1;
                //Invalidate();
            }        private void button2_Click(object sender, EventArgs e)
            {
                a = 0;
                Invalidate();
            }        private void Form1_Paint_1(object sender, PaintEventArgs e)
            {
                if (a == 1)
                {
                    Graphics g = this.CreateGraphics();
                    Pen pen1 = new Pen(Color.Blue, 2);
                    float y = 150, y1, x1, x2;
                    for (int x = 10; x < 1100; x++)
                    {
                        x1 = (float)x;
                        x2 = (float)(x + 1);
                        y1 = (float)(150 - 50 * Math.Sin((3.14159 / 180.0) * (x - 9)));
                        g.DrawLine(pen1, x1, y, x2, y1);
                        y = y1;
                    }
                    System.Drawing.Drawing2D.AdjustableArrowCap linecap = new System.Drawing.Drawing2D.AdjustableArrowCap(6, 6, false);
                    Pen pen2 = new Pen(Color.Blue, 3);                pen2.CustomEndCap = linecap;
                    g.DrawLine(pen2, 10, 300, 10, 0);
                    g.DrawLine(pen2, 10, 150, 1120, 150);
                }
            }
        }
    }