• 大小: 180KB
    文件类型: .rar
    金币: 2
    下载: 2 次
    发布日期: 2021-09-27
  • 语言: C#
  • 标签:

资源简介

C#绘制实时曲线,可放大局部图像 C#绘制实时曲线,可放大局部图像 C#绘制实时曲线,可放大局部图像 C#绘制实时曲线,可放大局部图像

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace 实时曲线绘制
{
    class draw
    {


        public Bitmap mybitmap;//用于双缓冲的位图,和画布等大

        Random rm = new Random();//随机数产生器


        public void DrawLineS(Color color float Xmax float Ymax PictureBox picbox Point[] ptlist)
        {
            mybitmap = new Bitmap(picbox.Width picbox.Height);//设定位图大小
            Graphics doublebufferg = Graphics.FromImage(mybitmap);//从位图上获取“画布”
            doublebufferg.Clear(Color.White);//用背景色刷新

            //pictureBox1填充为白色,便于显示图像  500*300
            Rectangle rect = new Rectangle(0 0 picbox.Width picbox.Height);
            doublebufferg.FillRectangle(new SolidBrush(Color.White) rect);
           
           
            //画X和Y轴
            DrawXY(ref doublebufferg picbox);
            //X轴上的刻度
            SetYAxis(ref doublebufferg picbox Ymax);
            //Y轴上的刻度
            SetXAxis(ref doublebufferg picbox Xmax);

            //要显示的实时曲线部分
            Point temp = new Point();
            for (int j = 0; j < picbox.Width/5 - 1; j++)
            {
                temp = ptlist[j + 1];
                ptlist[j] = new Point(temp.X - 5 temp.Y);
            }

            Point lastpt = new Point();
            lastpt.X = picbox.Width;
            lastpt.Y = rm.Next(DateTime.Now.Millisecond) % picbox.Height;
            ptlist[picbox.Width/5 - 1] = lastpt;
            doublebufferg.DrawLines(new Pen(color 1) ptlist);


            //将缓冲中的位图绘制到我们的窗体上
            Graphics g1 = picbox.CreateGraphics();//创建 PictureBox窗体的画布

            g1.Clear(Color.White);
            g1.DrawImage(mybitmap 0 0);

        } 


        //完成X轴和Y轴的基本部分
        public void  DrawXY(ref Graphics gPictureBox picbox)
        {
            Pen pen = new Pen(Color.Black 2);//画笔
            SolidBrush sb = new SolidBrush(Color.Black);//话刷
            
            //X轴的箭头,实际上是绘制了一个三角形
            Point[] xpts = new Point[3] { 
                new Point(picbox.Width - 35 picbox.Height - 32)
                new Point(picbox.Width - 35 picbox.Height - 28) 
                new Point(picbox.Width - 30 picbox.Height - 30) 
                                        };

            g.DrawLine(pen 30 picbox.Height - 30 picbox.Width - 30 picbox.Height - 30);
            g.DrawPolygon(pen xpts);
            g.DrawString(“X“ new Font(“宋体“ 9) sb picbox.Width - 25 picbox.Height - 35);



            //Y轴的箭头,实际上是绘制了一个三角形
            Point[] ypts = new Point[3] { 
                     new Point(28 35) 
                     new Point(30 30) 
                     new Point(32 35) };
              
            g.DrawLine(pen 30 picbox.Height - 30 30 30);
            g.DrawPolygon(pen ypts);
            g.DrawString(“Y“ new Font(“宋体“ 9) sb 15 30);
        
        }

      
        //绘制Y轴上的刻度

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

     文件        944  2009-10-13 16:40  实时曲线绘制\实时曲线绘制.sln

    ..A..H.     30208  2009-12-01 11:09  实时曲线绘制\实时曲线绘制.suo

     文件       4622  2009-10-13 16:40  实时曲线绘制\UpgradeLog.xml

     文件       3348  2009-10-13 16:40  实时曲线绘制\_UpgradeReport_Files\UpgradeReport.css

     文件         69  2009-10-13 16:40  实时曲线绘制\_UpgradeReport_Files\UpgradeReport_Minus.gif

     文件         71  2009-10-13 16:40  实时曲线绘制\_UpgradeReport_Files\UpgradeReport_Plus.gif

     文件      12505  2008-01-11 01:25  实时曲线绘制\_UpgradeReport_Files\UpgradeReport.xslt

     文件        944  2009-10-15 10:32  实时曲线绘制\Backup\实时曲线绘制.sln

    ..A..H.     17920  2009-10-15 13:39  实时曲线绘制\Backup\实时曲线绘制.suo

     文件       4727  2009-10-15 10:32  实时曲线绘制\Backup\UpgradeLog.xml

     文件       3348  2009-10-15 10:32  实时曲线绘制\Backup\_UpgradeReport_Files\UpgradeReport.css

     文件         69  2009-10-15 10:32  实时曲线绘制\Backup\_UpgradeReport_Files\UpgradeReport_Minus.gif

     文件         71  2009-10-15 10:32  实时曲线绘制\Backup\_UpgradeReport_Files\UpgradeReport_Plus.gif

     文件      12505  2008-01-11 01:25  实时曲线绘制\Backup\_UpgradeReport_Files\UpgradeReport.xslt

     文件        943  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制.sln

    ..A..H.     13312  2008-12-10 09:10  实时曲线绘制\Backup\Backup\实时曲线绘制.suo

     文件       3278  2008-12-09 20:18  实时曲线绘制\Backup\Backup\实时曲线绘制\实时曲线绘制.csproj

     文件       5339  2008-12-09 23:14  实时曲线绘制\Backup\Backup\实时曲线绘制\draw.cs

     文件       2078  2008-12-10 09:10  实时曲线绘制\Backup\Backup\实时曲线绘制\Form1.cs

     文件       3026  2008-12-09 20:26  实时曲线绘制\Backup\Backup\实时曲线绘制\Form1.Designer.cs

     文件        477  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制\Program.cs

     文件       6008  2008-12-09 20:24  实时曲线绘制\Backup\Backup\实时曲线绘制\Form1.resx

     文件       1208  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制\Properties\AssemblyInfo.cs

     文件       2890  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制\Properties\Resources.Designer.cs

     文件       1101  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制\Properties\Settings.Designer.cs

     文件        249  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制\Properties\Settings.settings

     文件       5612  2008-12-09 20:07  实时曲线绘制\Backup\Backup\实时曲线绘制\Properties\Resources.resx

     文件       5049  2009-10-15 13:34  实时曲线绘制\Backup\实时曲线绘制\实时曲线绘制.csproj

     文件      31064  2009-10-15 13:38  实时曲线绘制\Backup\实时曲线绘制\CurveControl.cs

     文件        348  2009-10-15 13:22  实时曲线绘制\Backup\实时曲线绘制\Form1.cs

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

评论

共有 条评论

相关资源