Esempio n. 1
0
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            double t = 0, n;
            int    x_v, y_v, x, y, x0, y0;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
            Desen.Clear(this.BackColor);
            x0  = (this.Width - 50) / 2;                              //jumatatea formularului
            y0  = (this.Height - 50) / 2;
            n   = System.Convert.ToDouble(this.numericUpDown1.Value); //numar spirale
            x_v = System.Convert.ToInt16(x0 + x0 * System.Math.Cos(n * t) * System.Math.Cos(t));
            y_v = System.Convert.ToInt16(y0 + y0 * System.Math.Cos(n * t) * System.Math.Sin(t));
            do
            {
                x = System.Convert.ToInt16(x0 + x0 * System.Math.Cos(n * t) * System.Math.Cos(t));
                y = System.Convert.ToInt16(y0 + y0 * System.Math.Cos(n * t) * System.Math.Sin(t));
                //Desen.DrawLine(Creion_albastru, x_v, y_v, x, y);
                x_v = x;
                y_v = y;
                t  += 0.001;//Rotunjimea
                do
                {
                    x = System.Convert.ToInt16(x0 + x0 * System.Math.Cos(n * t) * System.Math.Cos(t));
                    y = System.Convert.ToInt16(y0 + y0 * System.Math.Cos(n * t) * System.Math.Sin(t));
                    Desen.DrawLine(Creion_albastru, x_v, y_v, x, y);
                    x_v = x;
                    y_v = y;
                    t  += 0.001;//Rotunjimea
                }while (t <= 6.3);
            }while (t <= 6.3);
        }
Esempio n. 2
0
 private void Form1_Click(object sender, EventArgs e)
 {
     System.Drawing.Graphics Desen;
     System.Drawing.Pen      Creion_albastru;
     Desen           = this.CreateGraphics();
     Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
     Desen.DrawLine(Creion_albastru, mouse_rel_x() - 4, mouse_rel_y(), mouse_rel_x() + 4, mouse_rel_y());
     Desen.DrawLine(Creion_albastru, mouse_rel_x(), mouse_rel_y() - 4, mouse_rel_x(), mouse_rel_y() + 4);
 }
Esempio n. 3
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int   i = 0, lat, h;
            float x, ymax, y = 0, y_v = 0, k;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_gri_d;
            Creion_gri_d = new System.Drawing.Pen(System.Drawing.Color.LightGray);
            System.Drawing.Pen Creion_gri;
            Creion_gri = new System.Drawing.Pen(System.Drawing.Color.Gray);
            Desen.Clear(this.BackColor);
            System.Drawing.Pen Creion_rosu;
            Creion_rosu = new System.Drawing.Pen(System.Drawing.Color.Red);
            //Grid
            // linii verticale
            for (i = 0; i <= this.Width; i += 10)
            {
                if (i % 50 == 0)
                {
                    Desen.DrawLine(Creion_gri, i, 0, i, this.Height);
                }
                else
                {
                    Desen.DrawLine(Creion_gri_d, i, 0, i, this.Height);
                }
            }
            // linii orizontale

            for (i = 0; i <= this.Height; i += 10)
            {
                if (i % 50 == 0)
                {
                    Desen.DrawLine(Creion_gri, 0, i, this.Width, i);
                }
                else
                {
                    Desen.DrawLine(Creion_gri_d, 0, i, this.Width, i);
                }
            }
            // Trasare grafic x*x
            h    = this.Height - 50;
            i    = 0;
            lat  = this.Width - 20;
            ymax = (lat / 2) * (lat / 2); // ymax pe intervalul -lat/2... lat/2 este (lat/2)^2
            k    = h / ymax;              // factorul de scala
            for (x = -lat / 2; x <= lat / 2; x++)
            {
                y = h - k * x * x; // y=k*x^2
                Desen.DrawLine(Creion_rosu, i - 1, y_v, i, y);
                y_v = y;
                i  += 1;
            }
        }
Esempio n. 4
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i = 0;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_albastru;
            Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
            do
            {
                Desen.DrawLine(Creion_albastru, this.Width / 2, 0, i, this.Height - 30);
                i += 10;
            }while (i <= this.Width);
        }
Esempio n. 5
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i = 0;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_blue;
            Creion_blue = new System.Drawing.Pen(System.Drawing.Color.DeepSkyBlue);
            Desen.Clear(this.BackColor);
            do
            {
                int factor_s = this.Height / 2 - 22;
                int y        = System.Convert.ToInt16(5 + factor_s * (1 - System.Math.Sin(0.0314 * i)));
                Desen.DrawLine(Creion_blue, i, this.Height, i, y);
                i += 2;
            }while (i <= this.Width);
        }
Esempio n. 6
0
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     System.Drawing.Graphics Desen;
     Desen = this.CreateGraphics();
     System.Drawing.Pen Creion_albastru;
     Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
     System.Drawing.SolidBrush Pensula_roz;
     Pensula_roz = new System.Drawing.SolidBrush(System.Drawing.Color.Pink);
     Desen.FillRectangle(Pensula_roz, 100, 60, 300, 300);
     Desen.DrawRectangle(Creion_albastru, 105, 65, 290, 290);
     Desen.DrawEllipse(Creion_albastru, 105, 65, 290, 290);
     Desen.DrawEllipse(Creion_albastru, 145, 65, 200, 290);
     Desen.DrawLine(Creion_albastru, 250, 65, 250, 355);
     Desen.DrawLine(Creion_albastru, 105, 65, 395, 355);
     Desen.DrawLine(Creion_albastru, 105, 355, 395, 65);
     Desen.DrawLine(Creion_albastru, 105, 210, 395, 210);
 }
Esempio n. 7
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i = 0;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_gri_d;
            Creion_gri_d = new System.Drawing.Pen(System.Drawing.Color.LightGray);
            System.Drawing.Pen Creion_gri;
            Creion_gri = new System.Drawing.Pen(System.Drawing.Color.Gray);
            Desen.Clear(this.BackColor);

            // linii verticale
            while (i <= this.Width)
            {
                if (i % 50 == 0)
                {
                    Desen.DrawLine(Creion_gri, i, 0, i, this.Height);
                }
                else
                {
                    Desen.DrawLine(Creion_gri_d, i, 0, i, this.Height);
                }
                i += 10;
            }
            // linii orizontale
            i = 0;
            while (i <= this.Height)
            {
                if (i % 50 == 0)
                {
                    Desen.DrawLine(Creion_gri, 0, i, this.Width, i);
                }
                else
                {
                    Desen.DrawLine(Creion_gri_d, 0, i, this.Width, i);
                }
                i += 10;
            }
        }
Esempio n. 8
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int x1, y1, w, h;
            int nr_s = 20;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_g;
            Creion_g = new System.Drawing.Pen(System.Drawing.Color.LightGray, 2);
            System.Random n = new System.Random();
            Desen.Clear(this.BackColor);
            x1 = 0;
            do
            {
                y1 = 0;
                w  = 3 + n.Next(12);
                h  = n.Next(this.Height);
                Desen.DrawLine(Creion_g, x1, y1, x1 + w / 2, h);
                Desen.DrawLine(Creion_g, x1 + w, y1, x1 + w / 2, h);
                x1 = x1 + this.Width / nr_s;
            }while (x1 <= this.Width);
        }
Esempio n. 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            int       i = 0;
            const int nr_z = 31;
            int       poz_x = 14;             // pozitia curenta pe axa x
            float     w_r = 1, w_a = 3;       // grosimea(in pixeli) a liniei rosii respectiv albastre

            float[] consum = new float[nr_z]; // // vector ce pastreaza consumurile pe nr_z zile
            float   v_rand;                   // valoare aleatoare
            float   c_lun;                    // consum lunar
            float   c_med;                    // consum lunar mediu

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_rosu;
            Creion_rosu = new System.Drawing.Pen(System.Drawing.Color.Red, w_r);
            System.Drawing.Pen Creion_albastru;
            Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue, w_a);
            System.Random n = new System.Random();
            Desen.Clear(this.BackColor);
            Desen.DrawLine(Creion_rosu, 6, 0, 6, this.Height - 40);
            Desen.DrawLine(Creion_rosu, 6, this.Height - 40, this.Width - 20, this.Height - 40);
            for (i = 0; i < nr_z; i++)
            {
                v_rand = n.Next(this.Height - 40);// se genereaza o valoare aleatoare
                Desen.DrawLine(Creion_albastru, poz_x, this.Height - 40, poz_x, Height - 40 - v_rand);
                poz_x    += 14;
                consum[i] = v_rand;
            }
            c_lun = 0;
            for (i = 0; i < nr_z; i++)
            {
                c_lun = c_lun + consum[i];
            }
            //calculez si afisez consumul mediu
            c_med = c_lun / nr_z;
            Desen.DrawLine(Creion_rosu, 6, this.Height - 40 - c_med, this.Width - 20, this.Height - 40 - c_med);
        }
Esempio n. 10
0
 private void button1_Click(object sender, EventArgs e)
 {
     System.Drawing.Graphics Desen;
     Desen = this.CreateGraphics();
     System.Drawing.Pen        Creion_albastru;
     System.Drawing.SolidBrush Pensula_albastra;
     Pensula_albastra = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
     Creion_albastru  = new System.Drawing.Pen(System.Drawing.Color.Blue);
     if (this.radioButton1.Checked)
     {
         Desen.DrawLine(Creion_albastru, 150, 50, 350, 100);
     }
     if (this.radioButton2.Checked)
     {
         Desen.Clear(this.BackColor);
         Desen.DrawRectangle(Creion_albastru, 250, 50, 200, 100);
     }
     if (this.radioButton3.Checked)
     {
         Desen.Clear(this.BackColor);
         Desen.DrawEllipse(Creion_albastru, 250, 150, 105, 105);
     }
     if (this.radioButton4.Checked)
     {
         Desen.Clear(this.BackColor);
         Desen.DrawEllipse(Creion_albastru, 150, 50, 95, 200);
     }
     if (this.radioButton5.Checked)
     {
         Desen.Clear(this.BackColor);
         Desen.FillRectangle(Pensula_albastra, 250, 50, 200, 100);
     }
     if (this.radioButton6.Checked)
     {
         Desen.Clear(this.BackColor);
         Desen.FillEllipse(Pensula_albastra, 150, 50, 95, 200);
     }
 }