❔ CS0123No overload for 'CanvasMain_PreviewMouseMove' matches delegate for 'EventMouseHandler'
Basically i'm trying to make a system where there is a grid with moveable objects - if you drag the object to a certain position and let go, it will snap to the nearest grid cell. I have no clue what a delegate is or how to solve this error - I appreciate any help and here is the code below:
private void CanvasMain_PreviewMouseMove(object sender, MouseEventArgs e)
{
int numofcolumns = 2; //This is to work out the coordinates of the centre of each cell.
int numofrows = 2;
int displaywidth = 800;
int displayheight = 450;
int cellwidth = displaywidth / numofcolumns;
int cellheight = displayheight / numofrows;
if (this.dragObject == null)
return;
var position = e.GetPosition(sender as IInputElement);
Canvas.SetTop(this.dragObject, position.Y - this.offset.Y);
Canvas.SetLeft(this.dragObject, position.X - this.offset.X);
if (this.dragObject !=null)
{
System.Windows.Point offset = e.GetPosition(this.CanvasMain);
//Calculates position for object to snap to
double SnapX = (offset.X / cellwidth) * cellwidth + cellheight / 2;
double SnapY = (offset.Y / cellheight) * cellheight + cellwidth / 2;
}
}
private void CanvasMain_PreviewMouseMove(object sender, MouseEventArgs e)
{
int numofcolumns = 2; //This is to work out the coordinates of the centre of each cell.
int numofrows = 2;
int displaywidth = 800;
int displayheight = 450;
int cellwidth = displaywidth / numofcolumns;
int cellheight = displayheight / numofrows;
if (this.dragObject == null)
return;
var position = e.GetPosition(sender as IInputElement);
Canvas.SetTop(this.dragObject, position.Y - this.offset.Y);
Canvas.SetLeft(this.dragObject, position.X - this.offset.X);
if (this.dragObject !=null)
{
System.Windows.Point offset = e.GetPosition(this.CanvasMain);
//Calculates position for object to snap to
double SnapX = (offset.X / cellwidth) * cellwidth + cellheight / 2;
double SnapY = (offset.Y / cellheight) * cellheight + cellwidth / 2;
}
}