SoFunction
Updated on 2025-03-06

C# waveform diagram control production sample program


using System;
using ;
using ;
using ;
using ;
using ;
using ;

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

        int[] oldLine;
int SIZE = 15; //The size of the square
Pen LINEPEN = new Pen((3,64, 129), 1); //Background line color
Pen FORELINEPEN = new Pen(); //Foreground line color
        private void UserControl1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = ;
            int Bvalue;
            Bvalue = Value;
            if (shake != 0)
            {
                Random ro = new Random();
                int r = (0, shake);
                Value += ((-shake, 0) / 2) + r/2;
                if (Value>100)
                {
                    Value = 100;
                }
                if (Value < 0)
                {
                    Value = 0;
                }
            }
            int h = (int)( / SIZE);
int w = (int)( / SIZE )+ 1;//Add 1 here ensures that the rightmost vertical line appears in time when scrolling
            for (; h >= 0;h-- )
            {
                (LINEPEN, new Point(0, h * SIZE), new Point(, h * SIZE));
            }
            for (; w>=0;w-- )
            {
                (LINEPEN, new Point((w * SIZE) - limits, 0), new Point((w * SIZE) - limits, ));
            }
            for (int i = - 1,j = 0;i >j ;j++ )
            {
                (FORELINEPEN, new Point(j,( - (int)(((float)oldLine[j] / (float)100) * (float)) ) -1),
                    new Point(j + 1, ( - (int)(((float)oldLine[j+1] / (float)100) * (float)))-1) );
            }
            for (int i = - 1, j = 0; i > j; j++)
            {
                oldLine[j] = oldLine[j + 1];
            }
            oldLine[ - 1] = Value;
            pintLightPoint(e);
            Value = Bvalue;
        }

        private void pintLightPoint(PaintEventArgs e)
        {
            Graphics g = ;
(global::High_Tech_Watch.Resource1.Unt title_2,new Rectangle(new Point( - 50, - (int)(((float)lightPointValue / (float)100) * (float) ) - 10),new Size(20,20)));

        }

        int lightPointValue = 50;
int limits = 0;//Scrolling depends on him, it is a range
        private void timer1_Tick(object sender, EventArgs e)
        {
            limits++;
            if (limits >= SIZE)
            {
                limits = 0;
            }
            ();
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {

            oldLine = new int[ - 40];

        }

        int shake = 0;
[DefaultValue(0), Description("Juction rate, the value input by the value control automatically jitters (disabled is 0)"), Category("Attribute value")]
        public int Shake
        {
            get{return shake;}
            set{shake = value;}
        }
[DefaultValue(0),Description("current value"),Category("attribute value")]
        public int Value
        {
            get { return lightPointValue; }
            set { lightPointValue = value; }
        }
[Description("Current Value"), Category("Attribute Value")]
        public Pen LinePen
        {
            get { return LINEPEN; }
            set
            {
                LINEPEN = value;
                ();
            }
        }

        private void UserControl1_Resize(object sender, EventArgs e)
        {

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

        }
    }
}