Exemplo n.º 1
0
 // When this DragPictureBox is clicked
 public void MouseClicked(object sender, MouseEventArgs e)
 {
     Parent = Parent.Parent.Parent.Parent.Parent; // Gets and stores the Form this DragPictureBox is contained by
     Enabled = false; // Disables this component so that it can be placed when dragging has completed
     followMouse.Start(); // Start the followMouse timer to ensure that this DragPictureBox follows the mouse during dragging
     BringToFront(); // Bring this DragPictureBox to the front of the form
     activeDropGrid = ((GameForm)Parent).getDropGrid(); // Set the activeDropGrid by extracting this value from the parent form
     activeDropGrid.activeDragPB = this; // Update the active PictureBox of the extracted DropGrid to be this DragPictureBox
     UpdateSnappingRegion(activeDropGrid); // Update the snapping region stored by this DragPictureBox to the one defined by the extracted DropGrid
     DoDragDrop(Image, DragDropEffects.Copy); // Start a DragDrop operation
 }
Exemplo n.º 2
0
 // Used to update the snapping region held by this DragPictureBox
 public void UpdateSnappingRegion(DropGrid dropGrid)
 {
     currentSnapRegion = new SnappingRegion(dropGrid.GetSnappingRegion()); // Update the snapping region to the current state of the supplied DropGrid's snapping region
     currentSnapRegion.snapMode = (int)SnapMode; // Update the snap mode of our snapping region to the SnapMode of this DragPictureBox
     currentSnapRegion.AddImageOffsets(this); // Add the image offsets to our snapping region using this DragPictureBox
 }