资源简介

一个很好的画图例子,建立好坐标系后将随机取到的值画到坐标系里,随着时间的改变更新坐标系中得数值。有点像任务管理器里那个CUP信息得图!欢迎使用。。。*—*

资源截图

代码片段和文件信息

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

namespace huatu
{
    public partial class Form1 : Form huatu.myPenS
    {
        float[] d = new float[40] { 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
                                   0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0
            };
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }
        public void DrawImage()
        {

            //画图初始化    

            string[] month = new string[40] { “01“ “02“ “03“ “04“ “05“ “06“ “07“ “08“ “09“ “10“
                “11“ “12“ “13“ “14“ “15“ “16“ “17“ “18“ “19“ “20“
                “21“ “22“ “23“ “24“ “25“ “26“ “27“ “28“ “29“ “30“
                “31“ “32“ “33“ “34“ “35“ “36“ “37“ “38“ “39“ “40“};
            Random rnd = new Random();
            float j = (float)rnd.Next(140);
            for (int w = 39; w >= 0; w--)
            {
                if (w == 0)
                    d[0] = j;
                else
                    d[w] = d[w - 1];

            }
            //Random rnd2 = new Random(unchecked((int)DateTime.Now.Ticks));
            //for(int i=0;i<12;i++){
            //    d[i] = (float)rnd2.Next(50);
            //}
            Bitmap bMap = new Bitmap(1024 768);
            Graphics gph = Graphics.FromImage(bMap);
            gph.Clear(Color.White);

            PointF cPt = new PointF(40 420);//中心点    
            PointF[] xPt = new PointF[3]{//X轴三角形  
             new   PointF(cPt.Y+15+450cPt.Y) //X方向的表示箭头中心垂线得长度->即-
             new   PointF(cPt.Y+450cPt.Y-8)//XY表示箭头上半部分得大小,x大箭头向箭头向左
             new   PointF(cPt.Y+450cPt.Y+8)//XY表示箭头下半部分得大小,x大箭头向箭头向左
            };  
            PointF[] yPt = new PointF[3]{//Y轴三角形  
             new   PointF(cPt.XcPt.X-15)
             new   PointF(cPt.X+8cPt.X)
             new   PointF(cPt.X-8cPt.X)};  
            gph.DrawString(“N“ new Font(“宋体“ 14)
             Brushes.Black new PointF(cPt.X + 12 cPt.X));//图表标题    
            //画X轴    
            //gph.DrawLine(Pens.Black cPt.X cPt.Y cPt.Y cPt.Y);
            Pen blackPen = new Pen(Color.Black 3);
            //gph.DrawLine(Pens.Black cPt.X cPt.Y 1024 cPt.Y);
            gph.DrawLine(blackPen cPt.X cPt.Y 1024 cPt.Y);
           // gph.DrawPolygon(Pens.Black xPt);
            gph.FillPolygon(new SolidBrush(Color.Black) xPt);//箭头里面颜色填充为黑色
            ////取时间
            //Random rnd2 = new Random(unchecked((int)DateTime.Now.Ticks));     
            gph.DrawString(“时间“ new Font(“宋体“ 12) Brushes.Black new PointF(cPt.Y + 430 cPt.Y - 30));//时间得位置
            //画Y轴    
            gph.DrawLine(blackPen cPt.X cPt.Y cPt.X cPt.X);

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

     文件      24576  2008-09-15 14:52  huatu\huatu\bin\Debug\huatu.exe

     文件      24064  2008-09-15 14:52  huatu\huatu\bin\Debug\huatu.pdb

     文件       5917  2008-09-15 14:52  huatu\huatu\Form1.cs

     文件       2555  2008-09-15 14:49  huatu\huatu\Form1.Designer.cs

     文件       6008  2008-09-15 14:49  huatu\huatu\Form1.resx

     文件       3254  2008-09-15 12:10  huatu\huatu\huatu.csproj

     文件        842  2008-09-15 14:49  huatu\huatu\obj\Debug\huatu.csproj.GenerateResource.Cache

     文件      24576  2008-09-15 14:52  huatu\huatu\obj\Debug\huatu.exe

     文件        180  2008-09-15 14:49  huatu\huatu\obj\Debug\huatu.Form1.resources

     文件      24064  2008-09-15 14:52  huatu\huatu\obj\Debug\huatu.pdb

     文件        180  2008-09-14 23:41  huatu\huatu\obj\Debug\huatu.Properties.Resources.resources

     文件        254  2008-09-15 14:52  huatu\huatu\obj\huatu.csproj.FileList.txt

     文件        464  2008-09-14 23:39  huatu\huatu\Program.cs

     文件       1182  2008-09-14 23:39  huatu\huatu\Properties\AssemblyInfo.cs

     文件       2864  2008-09-14 23:39  huatu\huatu\Properties\Resources.Designer.cs

     文件       5612  2008-09-14 23:39  huatu\huatu\Properties\Resources.resx

     文件       1088  2008-09-14 23:39  huatu\huatu\Properties\Settings.Designer.cs

     文件        249  2008-09-14 23:39  huatu\huatu\Properties\Settings.settings

     文件        904  2008-09-14 23:39  huatu\huatu.sln

    ..A..H.     13824  2008-09-15 14:53  huatu\huatu.suo

     目录          0  2008-09-14 23:39  huatu\huatu\obj\Debug\TempPE

     目录          0  2008-09-14 23:42  huatu\huatu\bin\Debug

     目录          0  2008-09-15 14:52  huatu\huatu\obj\Debug

     目录          0  2008-09-14 23:39  huatu\huatu\bin

     目录          0  2008-09-14 23:41  huatu\huatu\obj

     目录          0  2008-09-14 23:39  huatu\huatu\Properties

     目录          0  2008-09-15 14:52  huatu\huatu

     目录          0  2008-09-14 23:39  huatu

     文件        104  2008-09-15 12:10  huatu\huatu\myPenS.cs

     目录          0  2008-09-15 12:09  huatu\huatu\obj\Debug\Refactor

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

评论

共有 条评论