I recently started learning programming in c#. First of all I drew a simple circle, but I have problem with "char" -e.Graphics. I have necessary namespaces like System.Drawing and System.windows.Form Program is concern with WPF Application. I would like to be able to enter the sizes and press a button to draw the circle.
namespace drawcircle
{
/// <summary>
/// Logika interakcji dla klasy MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void circle_Click(object sender, RoutedEventArgs e)
{
int iks = int.Parse(beginx.Text);
int igrek = int.Parse(beginy.Text);
int width = int.Parse(wid.Text);
int height = int.Parse(hei.Text);
draw.circle(iks, igrek, width, height);
}
class draw
{
public static void circle(int x, int y, int width, int height)
{
Pen color = new Pen(Color.Red);
System.Drawing.SolidBrush fillblack = new System.Drawing.SolidBrush(Color.Black);
Rectangle circle = new Rectangle(x, y, width, height);
Graphics g = e.Graphics;
g.DrawEllipse(color, circle);
}
}
}
}
e
isn't in scope indraw.circle
... You'll need to pass it in as a parameter to that method.public static void circle(int x, int y, int width, int height, RoutedEventArgs e)
would be the new signature, and call it likedraw.circle(iks, igrek, width, height, e);