Esempio n. 1
0
        void Timer1Tick(object sender, EventArgs e)
        {
            bool flag = false;

            for (var i = 0; i < values.Length; i++)
            {
                if (aux_values[i] < values[i])
                {
                    aux_values[i] += 0.15f;
                    flag           = true;
                }
                else
                {
                    aux_values[i] = values[i];
                }
            }

            if (flag)
            {
                //drawing of graphs

                bitmap.clear();

                for (int i = 0; i < 24; i++)
                {
                    bitmap.graph(26 * i, 150, aux_values[i], 22, 130, 0);
                }

                pic.Image = bitmap.getBitmap();
            }
        }
        public FormStatsOrigin(int[] val)
        {
            values = val;

            for (var i = 0; i < 24; i++)
            {
                createText("120", 300, 300);
            }

            InitializeComponent();

            bitmap = new Classes.Image(pic.Width, pic.Height);

            //loading of values

            Random rnd = new Random();

            for (var i = 0; i < values.Length; i++)
            {
                values[i] = rnd.Next(50);
            }

            //get max value

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] > max_value)
                {
                    max_value = values[i];
                }
            }

            //drawing of graphs

            int w = 26;

            if (max_value > 0)
            {
                bitmap.clear();

                for (int i = 0; i < 24; i++)
                {
                    float v = (float)(values[i] / max_value);

                    if (v < 0.162f && v != 0f)
                    {
                        v = 0.162f;
                    }

                    bitmap.graph(w * i, 150, v, 22, 130, 0);

                    int offx = 0;

                    texts[i].Text = "" + values[i];

                    if (values[i] < 10)
                    {
                        offx = 4;
                    }

                    texts[i].Location = new System.Drawing.Point(pic.Location.X + offx + w * i, (int)(pic.Location.Y + 125 - ((float)(values[i] / max_value) * 130)));

                    if (texts[i].Location.Y > pic.Location.Y + 130 - 25)
                    {
                        texts[i].Location = new System.Drawing.Point(pic.Location.X + offx + w * i, pic.Location.Y + 130 - 25);
                    }
                }

                pic.Image = bitmap.getBitmap();
            }
        }