hi all , so i have to make the user click once to make the rectangle appear where it clicks and then when you double click it is supposed to dissapear, i thought maybe to just translate it but in same color as backcolor but i cannot get graphics into the mousedown. please look at my code and see what i could insert into section at line
else if (e.Clicks == 2)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; public class Changerectangle : Form { private GraphicsPath p = new GraphicsPath(); private Region region; private int oldX = 100; private int oldY = 75; private Rectangle userrect = new Rectangle (50,50,100,100); public Changerectangle() { Size = new Size(400, 400); Text = "Rectangle"; BackColor = Color.White; p.AddRectangle(userrect); region = new Region(p); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.FillRegion(Brushes.Blue, region); base.OnPaint(e); } protected override void onmousedown(MouseEventArgs e) { if (e.Clicks == 1) { region = region.Clone(); region.Translate(e.X - oldX, e.Y - oldY); oldX = e.X; oldY = e.Y; Invalidate(); } else if (e.Clicks == 2) { } base.onmousedown(e); } protected override void onmouseup(MouseEventArgs e) { base.onmouseup(e); } static void Main() { Application.Run(new Changerectangle()); } }