private GraphicsPath m_gPath; private Pen m_pen; public MonControle() { // Cet appel est requis par le Concepteur de formulaires Windows.Forms. InitializeComponent(); // TODO : ajoutez les initialisations après l'appel à InitializeComponent m_gPath = new GraphicsPath(); m_gPath.AddLine(0,0,50,50); m_pen = new Pen(Brushes.Black, 5); }
private void MonControle_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { Point mousePosition = new Point(e.X, e.Y); if ( m_gPath.IsOutlineVisible(mousePosition, m_pen, this.CreateGraphics()) ) MessageBox.Show("Click!"); } private void MonControle_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { e.Graphics.DrawPath(m_pen, m_gPath); }