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; } }
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++; } }
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); } }
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); }
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)); } }
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); } }