I want to draw an circle from a method in another Class. But it says invalid parameters on line 41 and 42 in my class. When im done whith this project it should be an analog clock. and this is my first Project im unsing the drawing Event.Im undersatnding a shit and dont know how to fix my Problem. Im new in Forms. I allready tried to draw the circle in the main and it works fine but however it didnt work putting into a class. Im sorry for my classnames they might seem strange because im german. Thanks for your help.
Thats my class:
class Ziffernblatt
{
Size RectSize;
Point RectPoint = new Point(5, 10);
Rectangle Myrect;
Rectangle MyCircle;
Pen MyPen = new Pen(Color.Black, 1);
Pen Invpen = new Pen(Color.White, 1);
Graphics gObject;
public Ziffernblatt(Graphics NgObject)
{
gObject = NgObject;
}
public void Draw(int PosX, int PosY)
{
RectSize.Width = PosX / 2;
RectSize.Height = PosY / 2;
RectPoint.X = PosX / 2 - RectSize.Width / 2;
RectPoint.Y = PosY / 2 - RectSize.Height / 2;
Myrect = new Rectangle(RectPoint, RectSize);
MyCircle = new Rectangle(RectPoint, RectSize);
gObject.DrawRectangle(Pens.Red, Myrect);
gObject.DrawEllipse(Pens.Black, MyCircle);
}
and this is my main:
public partial class Form1 : Form
{
Ziffernblatt[] Ziffern = new Ziffernblatt[1];
Graphics gObject;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
gObject = e.Graphics;
Ziffern[0] = new Ziffernblatt(gObject);
}
private void Form1_SizeChanged(object sender, EventArgs e)
{
Ziffern[0].Draw(this.ClientSize.Width, this.ClientSize.Height);
Invalidate();
}
}