欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#波形圖控件制作示例程序

 更新時間:2013年11月29日 10:00:08   作者:  
這篇文章主要介紹了C#波形圖控件的制作方法,大家參考使用


首先添加一個timer,50s

復制代碼 代碼如下:

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

namespace High_Tech_Watch
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }

        int[] oldLine;
        int SIZE = 15; //方格的大小
        Pen LINEPEN = new Pen(Color.FromArgb(3,64, 129), 1); //背景線條顏色
        Pen FORELINEPEN = new Pen(Color.LightBlue);  //前景線條顏色
        private void UserControl1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            int Bvalue;
            Bvalue = Value;
            if (shake != 0)
            {
                Random ro = new Random();
                int r = ro.Next(0, shake);
                Value += (ro.Next(-shake, 0) / 2) + r/2;
                if (Value>100)
                {
                    Value = 100;
                }
                if (Value < 0)
                {
                    Value = 0;
                }
            }
            int h = (int)(this.Size.Height / SIZE);
            int w = (int)(this.Size.Width / SIZE )+ 1;//這里加1保證了滾動時最右側(cè)垂直線及時出現(xiàn)
            for (; h >= 0;h-- )
            {
                g.DrawLine(LINEPEN, new Point(0, h * SIZE), new Point(this.Size.Width, h * SIZE));
            }
            for (; w>=0;w-- )
            {
                g.DrawLine(LINEPEN, new Point((w * SIZE) - limits, 0), new Point((w * SIZE) - limits, this.Size.Height));
            }
            for (int i = oldLine.Length - 1,j = 0;i >j ;j++ )
            {
                g.DrawLine(FORELINEPEN, new Point(j,(this.Height - (int)(((float)oldLine[j] / (float)100) * (float)this.Height) ) -1),
                    new Point(j + 1, (this.Height - (int)(((float)oldLine[j+1] / (float)100) * (float)this.Height))-1) );
            }
            for (int i = oldLine.Length - 1, j = 0; i > j; j++)
            {
                oldLine[j] = oldLine[j + 1];
            }
            oldLine[oldLine.Length - 1] = Value;
            pintLightPoint(e);
            Value = Bvalue;
        }

        private void pintLightPoint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.DrawImage(global::High_Tech_Watch.Resource1.未標題_2,new Rectangle(new Point(this.Width - 50,this.Height - (int)(((float)lightPointValue / (float)100) * (float)this.Height ) - 10),new Size(20,20)));

        }

        int lightPointValue = 50;
        int limits = 0;//滾動就靠他了,是一個范圍
        private void timer1_Tick(object sender, EventArgs e)
        {
            limits++;
            if (limits >= SIZE)
            {
                limits = 0;
            }
            this.Invalidate();
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {

            oldLine = new int[this.Width - 40];

        }

        int shake = 0;
        [DefaultValue(0),Description("抖動率,值控件輸入的值自動抖動(禁用是為0)"),Category("屬性值")]
        public int Shake
        {
            get{return shake;}
            set{shake = value;}
        }
        [DefaultValue(0),Description("當前數(shù)值"),Category("屬性值")]
        public int Value
        {
            get { return lightPointValue; }
            set { lightPointValue = value; }
        }
        [Description("當前數(shù)值"), Category("屬性值")]
        public Pen LinePen
        {
            get { return LINEPEN; }
            set
            {
                LINEPEN = value;
                this.Invalidate();
            }
        }

        private void UserControl1_Resize(object sender, EventArgs e)
        {

            if ((this.Width - 40) > oldLine.Length)
            {
                 int[] newArry = new int[this.Width - 40];
                oldLine.CopyTo(newArry, newArry.Length - oldLine.Length);
                oldLine = new int[this.Width - 40];
                oldLine = newArry;
            }
            if ((this.Width - 40) < oldLine.Length)
            {
                int[] newArry = new int[this.Width - 40];
                for (int i = newArry.Length - 1,j = oldLine.Length - 1; i >=0 ;i--,j-- )
                {
                   newArry[i] = oldLine[j];
                }
                oldLine = new int[this.Width - 40];
                oldLine = newArry;
            }

        }
    }
}

相關(guān)文章

  • 測試框架nunit之a(chǎn)ssertion斷言使用詳解

    測試框架nunit之a(chǎn)ssertion斷言使用詳解

    NUnit是.Net平臺的測試框架,廣泛用于.Net平臺的單元測試和回歸測試中,下面我們用示例詳細學習一下他的使用方法
    2014-01-01
  • C#字符串內(nèi)存分配與駐留池學習分享

    C#字符串內(nèi)存分配與駐留池學習分享

    這篇文章主要介紹了C#字符串內(nèi)存分配與駐留池學習分享,大家參考使用吧
    2013-12-12
  • C# 實現(xiàn)拖拉控件改變位置與大小的方法

    C# 實現(xiàn)拖拉控件改變位置與大小的方法

    下面小編就為大家分享一篇C# 實現(xiàn)拖拉控件改變位置與大小的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • c#遞歸生成XML實例

    c#遞歸生成XML實例

    這篇文章主要介紹了c#遞歸生成XML的方法,以實例形式較為詳細的介紹了C#的遞歸算法與XML操作技巧,非常具有實用價值,需要的朋友可以參考下
    2014-11-11
  • C#中foreach語句深入研究

    C#中foreach語句深入研究

    這篇文章主要介紹了C#中foreach語句深入研究,本文通過手動實現(xiàn)迭代器來了解foreach語句的本質(zhì),揭示其原理,需要的朋友可以參考下
    2015-06-06
  • C# WinForm實現(xiàn)圖片瀏覽器

    C# WinForm實現(xiàn)圖片瀏覽器

    這篇文章主要為大家詳細介紹了C# WinForm實現(xiàn)圖片瀏覽器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-02-02
  • Winform開發(fā)框架中如何使用DevExpress的內(nèi)置圖標資源

    Winform開發(fā)框架中如何使用DevExpress的內(nèi)置圖標資源

    這篇文章主要給大家介紹了關(guān)于在Winform開發(fā)框架中如何使用DevExpress的內(nèi)置圖標資源的相關(guān)資料,文中通過圖文介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們一起來看看吧
    2018-12-12
  • Unity ScrollView實現(xiàn)無限循環(huán)效果

    Unity ScrollView實現(xiàn)無限循環(huán)效果

    這篇文章主要為大家詳細介紹了Unity ScrollView實現(xiàn)無限循環(huán)效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • C#調(diào)用dll報錯:無法加載dll,找不到指定模塊的解決

    C#調(diào)用dll報錯:無法加載dll,找不到指定模塊的解決

    這篇文章主要介紹了C#調(diào)用dll報錯:無法加載dll,找不到指定模塊的解決問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • C#中Ilist與list的區(qū)別小結(jié)

    C#中Ilist與list的區(qū)別小結(jié)

    本篇文章主要是對C#中Ilist與list的區(qū)別進行了詳細的總結(jié)介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-01-01

最新評論