/// <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(); } }
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; }
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); }
public int Position(LPOperator op) => Childs.IndexOf(op);