Exemple #1
0
        public Desk GetWrapNeighbor(Wnck.MotionDirection direction)
        {
            Desk desk;

            wrapneighbors.TryGetValue(direction, out desk);
            return(desk);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        public static Wnck.MotionDirection OppositeDirection(Wnck.MotionDirection direction)
        {
            switch (direction)
            {
            case MotionDirection.Down: return(MotionDirection.Up);

            case MotionDirection.Up: return(MotionDirection.Down);

            case MotionDirection.Left: return(MotionDirection.Right);

            case MotionDirection.Right:
            default: return(MotionDirection.Left);
            }
        }
Exemple #4
0
        public static Wnck.MotionDirection AlternateMovingDirection(Wnck.MotionDirection direction)
        {
            switch (direction)
            {
            case MotionDirection.Down: return(MotionDirection.Right);

            case MotionDirection.Up: return(MotionDirection.Left);

            case MotionDirection.Left: return(MotionDirection.Up);

            case MotionDirection.Right:
            default: return(MotionDirection.Down);
            }
        }
Exemple #5
0
        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);
        }