Witam mam za zadnie stworzyć program który będzie rysował figury na WindowsForm. Projekt ma być w jezyku c# i każda figura ma mieć własną klasę. Niestety ale poniższy kod się nie kompiluje gdy zadanie robię na klasach (gdy robiłem bez nich nie było problemu)
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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Kwadrat p = new Kwadrat();
p.create();
}
}
class Kwadrat
{
Graphics g;
Rectangle r;
Pen p;
public void create()
{
g = CreateGraphics();
p = new Pen(Brushes.DarkGreen);
r = new Rectangle(40, 40, 40, 40);
g.DrawEllipse(p, r);
}
}
}
Oto kod a błąd jest w tej lini
g = CreateGraphics();
a jego tresc to
CS0103 C# The name 'CreateGraphics' does not exist in the current context
Jak się z tym uporać ?