public static void SetCurrentColumnAfterMove(double movedTo, double columnSize, Node origin) { var nearestColumn = Convert.ToInt32(Math.Round(movedTo / columnSize)); if (nearestColumn != origin.Column) { nearestColumn = (nearestColumn < 0) ? 0 : nearestColumn; nearestColumn = (nearestColumn >= AppGlobals.PuzzleGridColumnCount) ? AppGlobals.PuzzleGridColumnCount - 1 : nearestColumn; var destination = new Node(origin.Row, nearestColumn); var orbMove = new OrbMove(origin, destination); MessageBus.Default.Notify("SwapOrbs", orbMove, new NotificationEventArgs()); } }
public static void SetCurrentRowAfterMove(Image image, Node origin) { var nearestRow = Convert.ToInt32(GetNearestRow(image)); if (nearestRow != origin.Row) { nearestRow = (nearestRow < 0) ? 0 : nearestRow; nearestRow = (nearestRow >= AppGlobals.PuzzleGridRowCount) ? AppGlobals.PuzzleGridRowCount - 1 : nearestRow; var destination = new Node(nearestRow, origin.Column); var orbMove = new OrbMove(origin, destination); MessageBus.Default.Notify("SwapOrbs", orbMove, new NotificationEventArgs()); origin.Row = nearestRow; } }
public OrbMove(Node origin, Node destination) { Origin = origin; Destination = destination; }
public void SetPosition(int row, int column) { Location = new Node(row, column); var gridHeight = AppGlobals.PuzzleGridActualHeight; var rowSize = gridHeight / AppGlobals.PuzzleGridRowCount; _dragTranslation.Y = row * rowSize; var screenWidth = Application.Current.Host.Content.ActualWidth; var columnSize = screenWidth / AppGlobals.PuzzleGridColumnCount; _dragTranslation.X = column * columnSize; }