I'm trying to develop an Block Coding application. I found it difficult to develop this kind of application.
With the events below, I can identify when there is a collision between other controls and drag the controls. However, I could not identify when I "step out" of the collision and when I release the control I'm dragging over another, in this case, it should reposition itself in a way that identifies the control tree. In the end, I'll create a code based on the added controls.
Am I doing it the right way? Is there any other simpler tool to develop applications of this type?
MouseDown Event
private void DynamicButton_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
MouseDownLocation = e.Location;
}
MouseMove Event
private void DynamicButton_MouseMove(object sender, MouseEventArgs e)
{
Button btn = (Button)sender;
foreach (Control item in Controls)
{
if (btn.Bounds.IntersectsWith(item.Bounds) && (item.Name != btn.Name))
{
item.BackColor = Color.Yellow;
}
}
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
btn.Left = e.X + btn.Left - MouseDownLocation.X;
btn.Top = e.Y + btn.Top - MouseDownLocation.Y;
}
}