• 大小: 77KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: C#
  • 标签: c#  chart  

资源简介

c# 用chart实时显示正玄波,有增大缩小功能(功能有待完善),X轴有两个竖直的游标,可以用鼠标拖动,Y轴也对应了一个可以拖动的中心轴,程序备注详细,适合初学者的借鉴,有什么指教也请留言。

资源截图

代码片段和文件信息

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using System.Runtime.InteropServices;

namespace zhengxuanbo
{
    public partial class Form1 : Form

    {
        public int x1 = 0;//X轴的值
        public Double y1;//Y轴的值
        public float pi = 3.14f;//π
        public float A = 10;         //Y轴系数
        public int B = 0;         //Y轴偏移量
        public int E =10;              //X轴变量每次增加的间隔
        public int X_size = 730;//x轴最大值
        public int X_intercal = 60;//X轴间隔
        public int X_viewsize = 360;//x可视大小,当可视区域小于轴的最大值时,滚动条出现
        public int Y_max = 20;//Y轴的最大值
        public int Y_min =-20;//Y轴的最小值
        public int Y_intercal = 6;//Y轴间隔    
        public int Y_viewsize = 36;//Y可视大小
        Series shuzhi = new Series();

       public int x_p1 x_p2x_scrall;//x_p1第一条竖线 x_p2第二条竖线x_scrall滚动条的值
        public int x_p1_offset=190 x_p2_offset=310;//鼠标的值
        public int x_difference;//chart原点和chartareas的差值

        public Form1()
        {
            InitializeComponent();         
        }
        private void Form1_Load(object sender EventArgs e)
        {
            Initchart();
            Init_trackbar();
            button1.Text = “开始“;
            button2.Text = “清屏“;
            button3.Text = “Y轴缩小“;
            button4.Text = “Y轴放大“;
            button5.Text = “X轴缩小“;
            button6.Text = “X轴放大“;
            B = trackBar1.Value;
            toolStripTextBox4.Text = trackBar1.Value.ToString();
            chart1.MouseMove += new MouseEventHandler(Chart1_MouseMove_x);
           

            x_difference = 72;




        }
       
        //private void Chart1_MouseMove(object sender MouseEventArgs e)
        //{

        //    textBox3.Text = e.X.ToString();
        //    textBox4.Text = e.Y.ToString();

        //    if (e.X >= (x_p1+69) & e.Y <= (x_p1 + 74))
        //    {
        //        this.Cursor = Cursors.NoMoveVert;

        //    }
        //    else
        //    {
        //        this.Cursor = Cursors.Default;
        //    }

        //}

        private void Chart1_MouseMove_x(object sender MouseEventArgs e)
        {

           
            if ((e.X >= (x_p1 - x_scrall + x_difference - 3) & e.X <= (x_p1 - x_scrall + x_difference + 3)) |
                (e.X >= (x_p2 - x_scrall + x_difference - 3) & e.X <= (x_p2 - x_scrall + x_difference + 3)))//减10是为了两线不重合
            {
                this.Cursor = Cursors.NoMoveHoriz;
                if (e.X >= (x_p1 - x_scrall + x_difference - 3) & e.X <= (x_p1 - x_scrall + x_difference + 3))
                {

                    if (e.Button == MouseButtons.Left)
                    {
                        x_p1_offset = e.X;
                        x_p1 = x_p1_offset - x_difference + x_scrall;
                        
                        drawXline(x_p1 x_p2 Color.Blue);

           

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     80896  2017-12-25 14:57  boxing2017\zhengxuanbo\.vs\zhengxuanbo\v14\.suo

     文件        189  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\App.config

     文件      27648  2017-12-25 14:56  boxing2017\zhengxuanbo\zhengxuanbo\bin\Debug\zhengxuanbo.exe

     文件        189  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\bin\Debug\zhengxuanbo.exe.config

     文件      32256  2017-12-25 14:56  boxing2017\zhengxuanbo\zhengxuanbo\bin\Debug\zhengxuanbo.pdb

     文件      22696  2017-12-25 14:57  boxing2017\zhengxuanbo\zhengxuanbo\bin\Debug\zhengxuanbo.vshost.exe

     文件        189  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\bin\Debug\zhengxuanbo.vshost.exe.config

     文件        490  2010-03-17 22:39  boxing2017\zhengxuanbo\zhengxuanbo\bin\Debug\zhengxuanbo.vshost.exe.manifest

     文件         60  2017-12-06 16:52  boxing2017\zhengxuanbo\zhengxuanbo\ClassDiagram1.cd

     文件      18027  2017-12-25 14:56  boxing2017\zhengxuanbo\zhengxuanbo\Form1.cs

     文件      23099  2017-12-25 14:55  boxing2017\zhengxuanbo\zhengxuanbo\Form1.Designer.cs

     文件      11030  2017-12-25 14:55  boxing2017\zhengxuanbo\zhengxuanbo\Form1.resx

     文件       2829  2017-12-16 22:31  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7398  2017-12-25 09:03  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件      11535  2017-12-25 14:57  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.csproj.FileListAbsolute.txt

     文件       1012  2017-12-25 14:55  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.csproj.GenerateResource.Cache

     文件       4788  2017-12-18 16:37  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.csprojResolveAssemblyReference.cache

     文件      27648  2017-12-25 14:56  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.exe

     文件       3672  2017-12-25 14:55  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.Form1.resources

     文件      32256  2017-12-25 14:56  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.pdb

     文件        180  2017-12-16 22:33  boxing2017\zhengxuanbo\zhengxuanbo\obj\Debug\zhengxuanbo.Properties.Resources.resources

     文件        523  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\Program.cs

     文件       1330  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\Properties\AssemblyInfo.cs

     文件       2835  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\Properties\Resources.Designer.cs

     文件       5612  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\Properties\Resources.resx

     文件       1098  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\Properties\Settings.Designer.cs

     文件        249  2017-12-03 12:54  boxing2017\zhengxuanbo\zhengxuanbo\Properties\Settings.settings

............此处省略18个文件信息

评论

共有 条评论