0

I have a Visual Basic PowerPacks Oval Shape control, displayed as a Circle on the form and I want to increase its size from the center of the last position, so that I can increase it from all sides i.e. the center, how can I do it, I tried this.

//This code to draw circle on the clicked area.

MouseEventArgs clickArgs = (MouseEventArgs)e; Graphics graphics = this.CreateGraphics();

float circlesize = 100;

int x = Convert.ToInt32(clickArgs.X - circlesize / 2);
int y = Convert.ToInt32(clickArgs.Y - circlesize / 2);

ovalShape1.Location = new Point(x, y);


//To increase its size        

 ovalShape1.Width = ovalShape1.Width + 10;
 ovalShape1.Height = ovalShape1.Height + 10;  

The Current code is increasing the size from the last X,Y Position which is not correct. :(

Huzaifa
  • 9
  • 2
  • It is not obvious how you plan to increase its size when you hard-code the diameter to 100. Consider that this needs to be two distinct operations, one to change its position and another to change its diameter. MouseWheel is often used to zoom an object. – Hans Passant Jul 05 '18 at 11:05
  • I am doing it using Mouse wheel only but, last 2 code lines get fired on mouse wheel only, but on how to change it diameter retaining the center point ? – Huzaifa Jul 05 '18 at 11:36
  • Simply increase the size and adjust the Location by -half the size increase. The Location adjustment is missing. – Hans Passant Jul 05 '18 at 11:53
  • Any Formula or calculation of it ?, – Huzaifa Jul 06 '18 at 11:32

0 Answers0