private void DragOverProjectionEventHandler(Object board, DragEventArgs projectionArgs) { CPieceProjection projection = projectionArgs.GetSingle <CPieceProjection>(); Point cursorCoordinates = projectionArgs.GetPosition((IInputElement)board); ChangeProjectionState(projection, cursorCoordinates); }
private CPieceProjection PutNewProjectionOnBoard(CPiece piece) { CPieceProjection projection = new CPieceProjection(piece); _attachedBoard.BoardCanvas.Children.Add(projection); Panel.SetZIndex(projection, (Int32)EZIndex.PieceProjection); return(projection); }
private void ChangeProjectionState(CPieceProjection projection, Point cursorCoordinates) { CTile cursorTile = new CTile(cursorCoordinates); projection.Margin = new Thickness(cursorTile.X * CPiece.PieceSize, cursorTile.Y * CPiece.PieceSize, 0, 0); projection.IsValidState = IsCursorOverBoard(cursorCoordinates) && !_attachedTiles.Contains(cursorTile) && projection.Root.IsMoveValid(_boardStates, cursorTile); }
private void MouseDownPieceEventHandler(Object pieceObject, MouseEventArgs args) { CPiece piece = (CPiece)pieceObject; if (piece.IsActive) { using CPieceProjection projection = PutNewProjectionOnBoard(piece); DragDrop.DoDragDrop(projection.Parent, projection, DragDropEffects.Move); } }
private void DropProjectionEventHandler(Object boardObject, DragEventArgs projectionArgs) { CPieceProjection projection = projectionArgs.GetSingle <CPieceProjection>(); if (projection.IsValidState) { projection.Root.AttachedTile = new CTile(projection.Margin); _attachedTiles.Add(projection.Root.AttachedTile); _virtualBoardService.TryMovePiece(_gameId, projection.Root.Id, new CPoint { X = projection.Margin.Left, Y = projection.Margin.Top }); } }