Kikx

Kikx

  • NA
  • 9
  • 12.3k

EventArg conversion into PaintEventArg

Jul 14 2012 11:20 AM
Greetings,

I have a college project which concerns C# and GDI/GDI+. The idea of the project is a very simple, primitive Paint program using GDI. It's due for September and I started now out of sheer boredom.
The task is to make a program that can create certain geometrical shapes (rectangles, ellipses), that can fill them with a desired color, and can draw lines using a pen (the color and width of the pen should be changeable). I have not done any work in GDI before, and after starting I have encountered my first issue, but one which I believe will follow me throughout the project.
A menu is required on the form, so I added one but cannot connect the menu strip items to certain tasks within the Form1_Paint event (due to the fact that the menustrip items have the EventArg argument and the paint method has PaintEventArg.)
I have encountered this while trying to create a method that would clear the form of all drawings.

private void ocisti(object sender, PaintEventArgs e)
        {
               
                e.Graphics.Clear(Color.White);
        }

...

private void ocistiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ocisti(sender, e);
        }

As I said, I have just started, there is almost zero functionality of the program, but I predict that I will be encountering this issue throughout the project, because I wish to put the selection of pen width/color and geometrical shapes on the menu strip.
How best to resolve this issue? And any other constructive advice?

(the errors: error CS1502: The best overloaded method match for 'Seminar_2.Form1.ocisti(System.Windows.Forms.PaintEventArgs)' has some invalid arguments
error CS1503: Argument 1: cannot convert from 'System.EventArgs' to 'System.Windows.Forms.PaintEventArgs')

Answers (5)