الكود اللى انا كاتبه ده الغرض منه رسم مستطيل بس بيطلع غلط ياريت حد يساعدنى فى انى اعرف فين الخطا
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace rectangle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
rect();
}
public void line(int x1, int x2, int y1, int y2)
{
Graphics g = pictureBox1.CreateGraphics();
Bitmap bm = new Bitmap(pictureBox1.Width, pictureBox1.Height);
int deltay, deltax, d1;
y2 = int.Parse(textBox1.Text);
y1 = int.Parse(textBox2.Text);
x2 = int.Parse(textBox3.Text);
x1 = int.Parse(textBox4.Text);
deltay = y2 - y1;
deltax = x2 - x1;
d1 = 2 * deltay - deltax;
for (int x = x1; x1 <= x2; x++)
{
if (d1 >= 0)
{
d1 = d1 + 2 * deltay - 2 * deltax;
y1++;
}
else
{
d1 = d1 + 2 * deltay;
}
g.DrawImage(bm, new Point(0, 0));
bm.SetPixel(x, y1, Color.Wheat);
}
}
public void rect()
{
int x1, x2, y1, y2;
line(x1,y1,x2,y1);
line(x1, y2, x2, y2);
line(x1, y2, x1, y1);
line(x2, y2, x2, y1);
}
}
}