private void MainEditorPanel_DragDrop(object sender, DragEventArgs e) { var agentDropped = e.Data.GetData(e.Data.GetFormats()[0]) as Agent; //Getting dropped data var newCoords = MainEditorPanel.PointToClient(new Point(e.X, e.Y)); //Getting client coords from screen var cellToEdit = EditingGrid.GetCellByXYCoord(newCoords.X - totalShiftVector.X, newCoords.Y - totalShiftVector.Y); //Getting cell from coords to add agent in it if (cellToEdit != null) { cellToEdit.InnerAgent = agentDropped; EditingGrid.AddOrReplaceCell(cellToEdit); } MainEditorPanel.Refresh(); }
/// <summary> /// Used for dragging and for updating mouse coords in the tool bar /// </summary> private void MainEditorPanel_MouseMove(object sender, MouseEventArgs e) { var currentCell = EditingGrid.GetCellByXYCoord(e.X - totalShiftVector.X, e.Y - totalShiftVector.Y); //Current cell that is covered with mouse if (currentTileBrush != null && currentCell != null) { brushCovering = EditingGrid.GetCellNeighboursOfRadius(currentCell, currentTileBrush.Size); #region Left mouse button for tile drawing if (leftMouseButtonInMapIsPressed) { foreach (var cell in brushCovering) { cell.PresentedTile = currentTileBrush.CurrentTile; EditingGrid.AddOrReplaceCell(cell); } } #endregion MainEditorPanel.Refresh(); } if (MouseCoordsChanged != null) { var newMouseEventArgs = new MouseEventArgs(e.Button, e.Clicks, e.X - totalShiftVector.X, e.Y - totalShiftVector.Y, e.Delta); MouseCoordsChanged(this, newMouseEventArgs); } #region Middle mouse button for dragging if (middleMouseButtonInMapIsPressed) { dragVector.X = e.X - mouseDownPoint.X; dragVector.Y = e.Y - mouseDownPoint.Y; MainEditorPanel.Refresh(); } #endregion }