1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void NoeudButton_Click(object sender, EventArgs e)
{
this.MouseClick += new MouseEventHandler(Form1_MouseClick);
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
this.MouseClick -= new MouseEventHandler(Form1_MouseClick);
drawCircle(e.X, e.Y);
//throw new NotImplementedException();
}
private void drawCircle(int x,int y)
{
Graphics g;
g= CreateGraphics();
Rectangle myRectangle = new Rectangle(x, y, 40, 40);
Pen myPen= new Pen(Color.Blue,4);
SolidBrush sb1 = new SolidBrush(Color.Black); // On crée un brush.
g.FillEllipse(sb1, new Rectangle(new Point(x, y), new Size(40,40)));
g.DrawEllipse(myPen,myRectangle);
g.Dispose();
}
}
} |
Partager