Kopiuj
class Pola
{
public int x;
public int y;
public typPola[,] rozmiar;
void rysuj(int x, int y, typPola[,] rozmiar)
{
Graphics graphics = this.CreateGraphics();
Pen p = new Pen(Color.Black, 4);
SolidBrush kolor_morze = new SolidBrush(Color.Aqua);
SolidBrush kolor_statek = new SolidBrush(Color.DarkGray);
SolidBrush kolor_zestrzelony = new SolidBrush(Color.Red);
SolidBrush kolor_pudlo = new SolidBrush(Color.DarkBlue);
for (int i = 0; i < 10; i++, x = x + 40)
{
for (int j = 0; j < 10; j++, y = y + 40)
{
if (rozmiar[i, j] == typPola.pudlo)
{
graphics.FillRectangle(kolor_pudlo, x, y, 40, 40);
graphics.DrawRectangle(p, x, y, 40, 40);
}
else if (rozmiar[i, j] == typPola.statek)
{
graphics.FillRectangle(kolor_statek, x, y, 40, 40);
graphics.DrawRectangle(p, x, y, 40, 40);
}
else if (rozmiar[i, j] == typPola.zestrzelone)
{
graphics.FillRectangle(kolor_zestrzelony, x, y, 40, 40);
graphics.DrawRectangle(p, x, y, 40, 40);
}
else
{
graphics.FillRectangle(kolor_morze, x, y, 40, 40);
graphics.DrawRectangle(p, x, y, 40, 40);
}
}
}
}
ewidentnie problem występuje z funkcją rysowania CreateGraphics(), Visual Studio wywala taki błąd:
Error 1 'statkiv3.Pola' does not contain a definition for 'CreateGraphics' and no extension method 'CreateGraphics' accepting a first argument of type 'statkiv3.Pola' could be found (are you missing a using directive or an assembly reference?) C:\Users\Luqaz\Desktop\STATKI - wersja z klasą, bez metody\statkiv3\Pola.cs 22 38 statkiv3