示例#1
0
        /// <summary>
        /// Child <see cref="IPanel.Closed"/> event handler.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event params.</param>
        private void OnChildClose(object sender, EventArgs e)
        {
            var panel = sender as IPanel;

            if (Childs.Contains(panel))
            {
                int panelIndex = Childs.IndexOf(panel);
                Childs.Remove(panel);

                if (Active == panel && Childs.Count > 0)
                {
                    // Todo: Make this configurable - after child panel is closed, make next OR prev child panel active.
                    int newActiveIndex = panelIndex < Childs.Count
                                                                ? panelIndex
                                                                : Childs.Count - 1;
                    Active = Childs[newActiveIndex];
                }
            }

            if (Childs.Count == 0 && !isClosing)
            {
                active = null;
                RequestClose();
            }
        }
示例#2
0
		private bool NextAction()
		{
			if (Childs.Count == 0)
				return false;

			if (_currentAction != null)
			{
				int index = Childs.IndexOf(_currentAction);
				if (index < 0 || index + 1 >= Childs.Count)
					return false;
				_currentAction = Childs[index + 1];
				_currentAction.Execute();
			}
			else
			{
				_currentAction = Childs[0];
				_currentAction.Execute();
			}
			return true;
		}
示例#3
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);
        }
示例#4
0
 public int Position(LPOperator op)
 => Childs.IndexOf(op);