最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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保證了滾動時最右側垂直線及時出現(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;
            }

        }
    }
}

相關文章

  • C#自定義簡化cookie類實例

    C#自定義簡化cookie類實例

    這篇文章主要介紹了C#自定義簡化cookie類,實例分析了C#操作cookie的添加、獲取及刪除等操作的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-03-03
  • C#?WPF?ListBox?動態(tài)顯示圖片功能

    C#?WPF?ListBox?動態(tài)顯示圖片功能

    這篇文章主要介紹了C#?WPF?ListBox?動態(tài)顯示圖片,處理過程分為前臺代碼和后臺代碼,本文結合實例代碼給大家介紹的非常詳細,需要的朋友可以參考下
    2023-08-08
  • Winform控件優(yōu)化之圓角按鈕1

    Winform控件優(yōu)化之圓角按鈕1

    這篇文章主要介紹了Winform控件優(yōu)化之圓角按鈕,文章圍繞主題展開詳細的內容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下
    2022-08-08
  • c# 中文轉拼音without CJK

    c# 中文轉拼音without CJK

    本文主要介紹了中文轉拼音without CJK,文章篇尾附上源碼下載。具有一定的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • c#使用dynamic類型優(yōu)化反射的方法

    c#使用dynamic類型優(yōu)化反射的方法

    dynamic是FrameWork4.0的新特性,下面這篇文章主要給大家介紹了關于c#使用dynamic類型優(yōu)化反射的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2018-12-12
  • asp.net獲取系統(tǒng)當前時間的方法詳解

    asp.net獲取系統(tǒng)當前時間的方法詳解

    這篇文章主要介紹了asp.net獲取系統(tǒng)當前時間的方法,較為詳細的分析了C#日期與時間操作所涉及的相關函數(shù)與使用技巧,需要的朋友可以參考下
    2016-06-06
  • C#設計模式之外觀模式介紹

    C#設計模式之外觀模式介紹

    外觀模式:為子系統(tǒng)中的一組接口提供一個一致的界面,此模式定義了一個高層的接口,這個借口使得這子系統(tǒng)容易使用
    2012-10-10
  • 深入理解C#指針之美

    深入理解C#指針之美

    在C#中,有時候希望通過指針來操作內存,這樣可以提高效率。我們可以用unsafe關鍵字修飾含有指針操作的程序段,感興趣的小伙伴可以參考一下,希望可以幫到你
    2021-07-07
  • .net2.0+ Winform項目實現(xiàn)彈出容器層

    .net2.0+ Winform項目實現(xiàn)彈出容器層

    在實際工作中,如果能像菜單一樣彈出自定義內容,會方便很多,比如查詢時,比如下拉列表顯示多列信息時,比如在填寫某個信息需要查看一些信息樹時。這個時候自定義彈出界面就顯的非常重要了
    2015-08-08
  • 舊項目升級新版Unity2021導致Visual?Studio無法使用的問題

    舊項目升級新版Unity2021導致Visual?Studio無法使用的問題

    在項目開發(fā)過程中,不可避免的會升級開發(fā)工具。這次我在舊項目版本升級到新版Unity2021.2.x時,出現(xiàn)Visual?Studio無法定位等問題,這里我給大家分享下解決方法,舊項目升級新版Unity2021導致Visual?Studio無法使用的問題,需要的朋友可以參考下
    2021-12-12

最新評論

八宿县| 武城县| 荥经县| 平山县| 黑水县| 浑源县| 大城县| 察隅县| 汝州市| 永城市| 南平市| 阿克| 连城县| 法库县| 临夏县| 开江县| 瑞安市| 左云县| 广安市| 民和| 安宁市| 宜川县| 望都县| 饶阳县| 句容市| 海林市| 定襄县| 尉犁县| 常德市| 湘乡市| 丰镇市| 西和县| 上栗县| 莎车县| 民权县| 洱源县| 隆昌县| 奎屯市| 新巴尔虎左旗| 南阳市| 平塘县|