title: How to use the Paint event to draw shapes at mouse coordinates
body: <p>I recently started programming in <code>C#</code> obviously and was trying to do a simple <code>WinForms</code> app that takes mouse coordinates and scales a Rectangle according to the coordinates.</p>
  <p>The issue I am facing is that I don't know how to call a method that uses more arguments (in this case is <code>x</code>, <code>y</code> and <code>PaintEventArgs</code>). Or, I do know what to do with the <code>PaintEvent</code>.</p>
  <p>Here is the whole code, since its pretty short and rather simple:</p>
  <pre><code>using System;
  using System.Drawing;
  using System.Windows.Forms;
  
  public partial class Form1 : Form
  {
      public void Form1_MouseMove(object sender, MouseEventArgs e)
      {
          int x = e.X; 
          int y = e.Y;
          String data = (x.ToString() + &quot; &quot; + y.ToString());
          DrawRect(Something, x, y);
      }
  
      PaintEventArgs pEventArgs;
      private void Form1_Paint(object sender, PaintEventArgs e)
      {
  
      }
  
      public void DrawRect(PaintEventArgs e, int rey, int rex)
      {
          Graphics gr = e.Graphics;
          Pen pen = new Pen(Color.Azure, 4);
          Rectangle rect = new Rectangle(0, 0, rex, rey);
          gr.DrawRectangle(pen, rect);
      }
  }
  </code></pre>
  <p>I'm trying to call the <code>DrawRect()</code> method to draw the Rectangle with <code>width</code> and <code>height</code> according to the mouse coordinates.</p>
  <p>So how can I call the <code>DrawRect()</code> with coordinates and <code>PaintEventArgs</code>?</p>