コード例 #1
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-7
        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);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-6
        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;
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-15
        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++;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-12
        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;
            }
        }
コード例 #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);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-3
        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);
        }
コード例 #7
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));
            }
        }
コード例 #8
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;
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-14
        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);
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: CorosMaria/MiniAplicatii-4
        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);
        }
コード例 #11
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);
     }
 }