public void SetNeighbor(Wnck.MotionDirection direction, Desk newneighbor) { Desk oldneighbor = GetNeighbor(direction); if (oldneighbor != null && oldneighbor != newneighbor) { neighbors.Remove(direction); if (oldneighbor.GetNeighbor(OppositeDirection(direction)) == this) { oldneighbor.SetNeighbor(OppositeDirection(direction), null); } } if (oldneighbor != newneighbor && newneighbor != null) { neighbors.Add(direction, newneighbor); if (GetNeighbor(OppositeDirection(direction)) == null) { Desk oldwrapneighbor = newneighbor.GetWrapNeighbor(OppositeDirection(direction)); if (oldwrapneighbor != null) { SetWrapNeighbor(OppositeDirection(direction), oldwrapneighbor); } else { SetWrapNeighbor(OppositeDirection(direction), newneighbor); } } newneighbor.SetNeighbor(OppositeDirection(direction), this); } }
public Desk[,] GetDeskGridLayout() { Desk next, desk = GetUpperLeftDesk(); Gdk.Point gridsize = GetDeskGridSize(); Desk [,] grid = new Desk [gridsize.X, gridsize.Y]; grid [0, 0] = desk; int x = 0; for (int y = 0; y < gridsize.Y; y++) { x = 0; while ((next = desk.GetNeighbor(Wnck.MotionDirection.Right)) != null) { desk = next; x++; if (gridsize.X - 1 < x) { break; } grid [x, y] = desk; } if (gridsize.Y - 1 > y) { desk = (grid [0, y] != null ? grid [0, y].GetNeighbor(Wnck.MotionDirection.Down) : null); grid [0, y + 1] = desk; } } return(grid); }
bool SwitchDesk(Wnck.MotionDirection direction) { Desk activedesk = Desks.Find(desk => desk.IsActive); Desk nextdesk = activedesk.GetNeighbor(direction); if (WrappedScrolling) { // Walk through the columns/rows and jump between [1,1] and [n,m] Desk tmp = activedesk.GetWrapNeighbor(direction); if (tmp != null && (nextdesk = tmp.GetNeighbor(Desk.AlternateMovingDirection(direction))) == null) { if ((nextdesk = tmp.GetWrapNeighbor(Desk.AlternateMovingDirection(direction))) == null) { nextdesk = tmp; } } } if (nextdesk != null) { nextdesk.Activate(); return(true); } return(false); }