Beispiel #1
0
        public override bool TransferNode(Node child, Node nodeToTransfer, TransferDirection direction, bool nodeGotFocus)
        {
            var i = Childs.IndexOf(child);

            if (i == -1)
            {
                return(false);
            }

            if ((Direction == Direction.Horizontal && (direction == TransferDirection.Up || direction == TransferDirection.Down)) ||
                (Direction == Direction.Vertical && (direction == TransferDirection.Left || direction == TransferDirection.Right)))
            {
                // It would seem strange if an node that is moved up ends up to the left/right on an horizontal node.. so lets just move it further up
                // It would seem strange if an node that is moved left ends up above/below on an vertical node.. so lets just move it further up
                return(Parent?.TransferNode(this, nodeToTransfer, direction, nodeGotFocus) ?? false);
            }

            switch (direction)
            {
            case TransferDirection.Left:
                if (i == 0)
                {
                    return(false);
                }

                if (Childs[i - 1].CanHaveChilds == false)
                {
                    return(false);
                }

                return(Childs[i - 1].TransferNode(null, nodeToTransfer, direction, nodeGotFocus));

            case TransferDirection.Up:
                if (i == 0)
                {
                    return(false);
                }

                if (Childs[i - 1].CanHaveChilds == false)
                {
                    return(false);
                }

                return(Childs[i - 1].TransferNode(null, nodeToTransfer, direction, nodeGotFocus));

            case TransferDirection.Right:
                if (i == Childs.Count - 1)
                {
                    return(false);
                }

                if (Childs[Childs.Count - 1].CanHaveChilds == false)
                {
                    return(false);
                }

                return(Childs[Childs.Count - 1].TransferNode(null, nodeToTransfer, direction, nodeGotFocus));

            case TransferDirection.Down:
                if (i == Childs.Count - 1)
                {
                    return(false);
                }

                if (Childs[Childs.Count - 1].CanHaveChilds == false)
                {
                    return(false);
                }

                return(Childs[Childs.Count - 1].TransferNode(null, nodeToTransfer, direction, nodeGotFocus));

            default:
                Log.Error($"{nameof(FixedContainerNode)}.{nameof(TransferNode)} was called with unknown {nameof(TransferDirection)} ({direction.ToString()})");
                break;
            }

            return(false);
        }
Beispiel #2
0
        public override void ChildWantMove(Node child, TransferDirection direction)
        {
            switch (direction)
            {
            case TransferDirection.Left:
                Log.Warning($"{nameof(FixedContainerNode)}.{nameof(ChildWantMove)} was called with Left, ({child.GetType()}) but Fixed container cannot change its childs nodes");
                break;

            case TransferDirection.Up:
                Log.Warning($"{nameof(FixedContainerNode)}.{nameof(ChildWantMove)} was called with up, ({child.GetType()}) but Fixed container cannot change its childs nodes");
                break;

            case TransferDirection.Right:
                Log.Warning($"{nameof(FixedContainerNode)}.{nameof(ChildWantMove)} was called with right, ({child.GetType()}) but Fixed container cannot change its childs nodes");
                break;

            case TransferDirection.Down:
                Log.Warning($"{nameof(FixedContainerNode)}.{nameof(ChildWantMove)} was called with down, ({child.GetType()}) but Fixed container cannot change its childs nodes");
                break;

            default:
                Log.Error($"{nameof(ContainerNode)}.{nameof(ChildWantMove)} was called with unknown {typeof(TransferDirection).ToString()} ({direction.ToString()})");
                break;
            }
        }
Beispiel #3
0
        public override bool TransferNode(Node child, Node nodeToTransfer, TransferDirection direction, bool nodeGotFocus)
        {
            var i = child == null ? Childs.Count : Childs.IndexOf(child);

            if (i == -1)
            {
                return(false);
            }

            if (child != null &&
                ((Direction == Direction.Horizontal && (direction == TransferDirection.Up || direction == TransferDirection.Down)) ||
                 (Direction == Direction.Vertical && (direction == TransferDirection.Left || direction == TransferDirection.Right))))
            {
                // It would seem strange if an node that is moved up ends up to the left/right on an horizontal node.. so lets just move it further up
                // It would seem strange if an node that is moved left ends up above/below on an vertical node.. so lets just move it further up
                return(Parent?.TransferNode(this, nodeToTransfer, direction, nodeGotFocus) ?? false);
            }

            switch (direction)
            {
            case TransferDirection.Left:
            {
                InsertChildAt(nodeToTransfer, i);
                RecalcDeltaWithHeight();

                // Only ask parent to recalc if the call is not from parent (child != null)
                if (!TryUpdateChildRect(0, Childs.Count, out RECT newRect) && child != null)
                {
                    base.UpdateRect(newRect);
                    RecalcDeltaWithHeight();
                    OnRequestRectChange(this, new RequestRectChangeEventArg(this, Rect, newRect));
                }

                if (_isVisible)
                {
                    nodeToTransfer.Show();
                }
                else
                {
                    nodeToTransfer.Hide();
                }

                if (nodeGotFocus)
                {
                    Desktop.FocusTracker.UpdateFocusTree();
                }
                return(true);
            }

            case TransferDirection.Up:
            {
                InsertChildAt(nodeToTransfer, i);
                RecalcDeltaWithHeight();

                // Only ask parent to recalc if the call is not from parent (child != null)
                if (!TryUpdateChildRect(0, Childs.Count, out RECT newRect) && child != null)
                {
                    base.UpdateRect(newRect);
                    RecalcDeltaWithHeight();
                    OnRequestRectChange(this, new RequestRectChangeEventArg(this, Rect, newRect));
                }

                if (_isVisible)
                {
                    nodeToTransfer.Show();
                }
                else
                {
                    nodeToTransfer.Hide();
                }

                if (nodeGotFocus)
                {
                    Desktop.FocusTracker.UpdateFocusTree();
                }
                return(true);
            }

            case TransferDirection.Right:
            {
                InsertChildAt(nodeToTransfer, child == null ? 0 : Math.Min(Childs.Count, i + 1));
                RecalcDeltaWithHeight();

                // Only ask parent to recalc if the call is not from parent (child != null)
                if (!TryUpdateChildRect(0, Childs.Count, out RECT newRect) && child != null)
                {
                    base.UpdateRect(newRect);
                    RecalcDeltaWithHeight();
                    OnRequestRectChange(this, new RequestRectChangeEventArg(this, Rect, newRect));
                }

                if (_isVisible)
                {
                    nodeToTransfer.Show();
                }
                else
                {
                    nodeToTransfer.Hide();
                }

                if (nodeGotFocus)
                {
                    Desktop.FocusTracker.UpdateFocusTree();
                }
                return(true);
            }

            case TransferDirection.Down:
            {
                InsertChildAt(nodeToTransfer, child == null ? 0 : Math.Min(Childs.Count, i + 1));
                RecalcDeltaWithHeight();

                // Only ask parent to recalc if the call is not from parent (child != null)
                if (!TryUpdateChildRect(0, Childs.Count, out RECT newRect) && child != null)
                {
                    base.UpdateRect(newRect);
                    RecalcDeltaWithHeight();
                    OnRequestRectChange(this, new RequestRectChangeEventArg(this, Rect, newRect));
                }

                if (_isVisible)
                {
                    nodeToTransfer.Show();
                }
                else
                {
                    nodeToTransfer.Hide();
                }

                if (nodeGotFocus)
                {
                    Desktop.FocusTracker.UpdateFocusTree();
                }
                return(true);
            }

            default:
                Log.Error($"{nameof(ContainerNode)}.{nameof(TransferNode)} was called with unknown {typeof(TransferDirection).ToString()} ({direction.ToString()})");
                break;
            }

            return(false);
        }
Beispiel #4
0
        public override void ChildWantMove(Node child, TransferDirection direction)
        {
            switch (direction)
            {
            case TransferDirection.Left:
                MoveChildLeft(child);
                break;

            case TransferDirection.Up:
                MoveChildUp(child);
                break;

            case TransferDirection.Right:
                MoveChildRight(child);
                break;

            case TransferDirection.Down:
                MoveChildDown(child);
                break;

            default:
                Log.Error($"{nameof(ContainerNode)}.{nameof(ChildWantMove)} was called with unknown {typeof(TransferDirection).ToString()} ({direction.ToString()})");
                break;
            }
        }
Beispiel #5
0
        public override bool FocusNodeInDirection(Node focusNode, TransferDirection direction)
        {
            if (focusNode.Style == NodeStyle.FullscreenOne)
            {
                return(Parent?.FocusNodeInDirection(focusNode, direction) ?? false);
            }

            if (focusNode == this)
            {
                return(Parent?.FocusNodeInDirection(focusNode, direction) ?? false);
            }

            var i = Childs.IndexOf(focusNode);

            if (i == -1)
            {
                return(false);
            }

            switch (direction)
            {
            case TransferDirection.Left:
                if (Direction == Direction.Vertical || Childs.Count == 1 || i == 0)
                {
                    return(Parent?.FocusNodeInDirection(this, direction) ?? false);
                }

                i--;
                Childs[i].SetFocus(direction);
                return(true);

            case TransferDirection.Right:
                if (Direction == Direction.Vertical || Childs.Count == 1 || i == Childs.Count - 1)
                {
                    return(Parent?.FocusNodeInDirection(this, direction) ?? false);
                }

                i++;
                Childs[i].SetFocus(direction);
                return(true);

            case TransferDirection.Up:
                if (Direction == Direction.Horizontal || Childs.Count == 1 || i == 0)
                {
                    return(Parent?.FocusNodeInDirection(this, direction) ?? false);
                }

                i--;
                Childs[i].SetFocus(direction);
                return(true);

            case TransferDirection.Down:
                if (Direction == Direction.Horizontal || Childs.Count == 1 || i == Childs.Count - 1)
                {
                    return(Parent?.FocusNodeInDirection(this, direction) ?? false);
                }

                i++;
                Childs[i].SetFocus(direction);
                return(true);

            default:
                Log.Error($"{nameof(ContainerNode)}.{nameof(FocusNodeInDirection)} was called with unknown {nameof(TransferDirection)} ({direction.ToString()})");
                break;
            }

            return(false);
        }