Beispiel #1
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i, x1, y1, w, h;

            System.Drawing.Graphics   Desen;
            System.Drawing.SolidBrush Pens_g, Pens_w;
            System.Drawing.Pen        Creion_g;
            Desen    = this.CreateGraphics();
            Pens_g   = new System.Drawing.SolidBrush(System.Drawing.Color.LightGray);
            Pens_w   = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke);
            Creion_g = new System.Drawing.Pen(System.Drawing.Color.Gray, 3);
            System.Random n = new System.Random();
            Desen.Clear(this.BackColor);
            i = 0;
            while (i <= 50)
            {
                x1 = n.Next(this.Width);
                y1 = n.Next(this.Height);
                w  = n.Next(75);
                h  = this.Height - y1;
                if (i % 2 == 0)
                {
                    Desen.DrawRectangle(Creion_g, x1, y1, w, h);
                    Desen.FillRectangle(Pens_g, x1 + 1, y1 + 1, w - 1, h - 1);
                }
                else
                {
                    Desen.DrawRectangle(Creion_g, x1, y1, w, h);
                    Desen.FillRectangle(Pens_w, x1 + 1, y1 + 1, w - 1, h - 1);
                }
                i++;
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i, j, h, w, d, m = 3, n = 10;

            // j contor dreptunghiuri
            // i contor dreptunghiuri concentrice
            // m nr dreptunghiuri
            // n nr dreptunghiuri concentrice
            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_albastru;
            Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
            Desen.Clear(this.BackColor);
            h = this.Height - 30; //inaltimea maxima a dreptunghiurilor
            w = this.Width / m;   //latimea maxima a dreptunghiului
            d = w / 2 / n;        // distanta intre doua dreptunghiuri concentrice
            j = 0;
            while (j <= m * w)
            {
                i = 0;
                while (i <= d * n)
                {
                    Desen.DrawRectangle(Creion_albastru, j + i + 10, i + 10, (w - 20 - 2 * i), (h - 20 - 2 * i));
                    i += d;
                }
                j += w;
            }
        }
Beispiel #4
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);
 }
Beispiel #5
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;
            }
        }
Beispiel #6
0
        private void Form1_DoubleClick(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.DrawEllipse(Creion_albastru, mouse_rel_x() - 20, mouse_rel_y() - 20, 40, 40);

            for (int i = 1; i <= 5; i++)
            {
                Desen.DrawEllipse(Creion_albastru, mouse_rel_x() - i * 10, mouse_rel_y() - i * 10, 2 * i * 10, 2 * i * 10);
            }
        }
Beispiel #7
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);
        }
Beispiel #8
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int x0, y0, w, h, i;

            x0 = 200;
            y0 = 150;
            w  = 200;
            h  = 100;
            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_albastru;
            Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
            for (i = 1; i <= 15; i++)
            {
                Desen.DrawRectangle(Creion_albastru, x0 - i * 5, y0 - i * 5, w, h);
            }
        }
Beispiel #9
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);
        }
Beispiel #10
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);
 }
Beispiel #11
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int  i      = 0;
            bool repeta = true;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_rosu;
            System.Drawing.Pen Creion_albastru;
            System.Random      n = new System.Random();
            Desen.Clear(this.BackColor);
            i = 0;
            for (i = 1; i <= 100; i++)
            {
                Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.FromArgb(n.Next(256), n.Next(256), n.Next(256)));
                Creion_rosu     = new System.Drawing.Pen(System.Drawing.Color.FromArgb(n.Next(256), n.Next(256), n.Next(256)));
                Desen.DrawRectangle(Creion_albastru, n.Next(this.Width), n.Next(this.Height), n.Next(75), n.Next(50));
                Desen.DrawEllipse(Creion_rosu, n.Next(this.Width), n.Next(this.Height), n.Next(50), n.Next(75));
            }
        }
Beispiel #12
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i, x0, y0, w;

            System.Drawing.Graphics Desen;
            System.Random           n;
            System.Drawing.Pen      Creion_albastru;
            Desen           = this.CreateGraphics();
            Creion_albastru = new System.Drawing.Pen(System.Drawing.Color.Blue);
            n = new System.Random();
            w = 30;
            i = 0;
            do
            {
                x0 = n.Next(this.Width - w);
                y0 = n.Next(this.Height - w);
                Desen.DrawEllipse(Creion_albastru, x0, y0, w, w);
                i++;
            }while (i < 20);
        }
Beispiel #13
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int i = 0, j = 0;

            System.Drawing.Graphics Desen;
            Desen = this.CreateGraphics();
            System.Drawing.Pen Creion_rosu;
            Creion_rosu = new System.Drawing.Pen(System.Drawing.Color.Red);
            Desen.Clear(this.BackColor);
            do
            {
                i = 0;
                do
                {
                    Desen.DrawEllipse(Creion_rosu, i, j, 25, 25);
                    i += 30;
                } while (i <= this.Width - 30);
                j += 30;
            } while (j <= this.Height - 50);
        }
Beispiel #14
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;
            }
        }
Beispiel #15
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);
        }
Beispiel #16
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);
     }
 }
Beispiel #17
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);
        }