Sie sind auf Seite 1von 3

72.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)


{
Graphics g = e.Graphics;
int A = ClientRectangle.Height, B = ClientRectangle.Height;
for(int y = 0; y <= A; y += A / 45)
{
g.DrawLine(Pens.Red, 0, 0, B, y);
g.DrawLine(Pens.Indigo, 0, A, B, y);
}
}

private void Form1_Resize(object sender, EventArgs e)


{
Refresh();
}
}
}
71 .

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _73.stepenice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)


{
Graphics g = e.Graphics;
int x = 0, y = ClientRectangle.Height;
while (x<ClientRectangle.Width && y>0)
{
g.DrawLine(Pens.Red, x, y, x, y - 20);
g.DrawLine(Pens.Red, x, y - 20, x + 20, y - 20);
x += 20;
y -= 20;
}
}

private void Form1_Resize(object sender, EventArgs e)


{
Refresh();
}
}
}
73.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Button1_Click(object sender, EventArgs e)


{
int x, y, d;
try
{
d = Convert.ToInt32(textBox1.Text);
}
catch
{
MessageBox.Show("Neispravna duzina stranice podaci", "Greska");
textBox1.SelectAll();
textBox1.Focus();
return;
}
Graphics g = CreateGraphics();
Random r = new Random();
Pen olovka = new Pen(Color.Blue, 2);
Refresh();
x = ClientRectangle.Width / 2;
y = panel1.Height + (ClientRectangle.Height - panel1.Height) / 2;
while (d < 0)
{
olovka.Color = Color.FromArgb(r.Next(150), r.Next(150), 255);
g.DrawRectangle(olovka, x - d/2, y - d/2, d, d);
d = d - 20;
}
olovka.Dispose();
g.Dispose();
}
}
}

Das könnte Ihnen auch gefallen