public bool CanAddParent(Person parent) { if (Parents.Count() == 2) { return(false); } return(!Parents.Any(m => m.Gender == parent.Gender)); }
public void CalculateLevel() { if (Parents.Count() == 0) { this.Level = 0; return; } foreach (var parent in this.Parents) { parent.CalculateLevel(); } this.Level = Parents.Select(p => p.Level).Max() + 1; }
public override bool RemoveFromParent(GroupNode <Element> parent, bool cleanupIfFloating) { bool result = base.RemoveFromParent(parent, cleanupIfFloating); // if we're cleaning up if we're a floating node (eg. being deleted), and we're actually // floating, then remove the associated element (if any) if (cleanupIfFloating && Parents.Count() == 0) { Element = null; VixenSystem.Nodes.ClearElementNode(Id); } OnChanged(this); return(result); }
public override bool RemoveFromParent(GroupNode <Element> parent, bool cleanup) { bool result = base.RemoveFromParent(parent, cleanup); // if we're cleaning up after removal (eg. being deleted), and we're actually floating // (ie. this node doesn't exist anywhere else), remove the associated element (if any) if (cleanup && Parents.Count() == 0) { if (Element != null) { VixenSystem.Elements.RemoveElement(Element); Element = null; } VixenSystem.Nodes.ClearElementNode(Id); } OnChanged(this); return(result); }
public virtual bool RemoveFromParent(GroupNode <T> parent, bool cleanupIfFloating) { // try to remove this node from the given parent. if (!parent.RemoveChild(this)) { return(false); } // if we don't have any parents left, we're floating free: recurse down, and // remove all children from this node. (This retains children that are also // children of other nodes, not just this one). if (cleanupIfFloating && Parents.Count() == 0) { foreach (GroupNode <T> child in _children.ToList()) { child.RemoveFromParent(this, cleanupIfFloating); } } return(true); }
protected override void OnStateUpdated(ViewStates state) { if (this._parentsRetriever == null) //this function may endups being called before instance is fully constructed { return; } var parent = this.RetrieveParent(this.CurrentItem); if (State == ViewStates.Creating || State == ViewStates.UpdatingCreate || State == ViewStates.UpdatingViewing || State == ViewStates.Updating) { Parents = this._parentsRetriever(); } if (parent != null && Parents.Count() > 0) { var itemParent = Parents.First(cat => cat.Id.Equals(parent.Id)); this.SetParent(this.CurrentItem, itemParent); } }
private int CalculateStatus() { try { var status = (int)NodeStatus.None; if (CanInput) { switch (this.NodeType) { case NodeType.Start: case NodeType.Normal: var details = Details; status = (details == null || details.Length == 0) ? (int)NodeStatus.Disable : Rule4Status.GetStatus(details, Context.Task.Variables); break; case NodeType.Control: case NodeType.End: status = this.Data != null ? (int)NodeStatus.Approved : (int)NodeStatus.Disable; break; } } else { if (Parents.Any(n => n.Status == (int)NodeStatus.Error)) { throw new ApplicationException("Parent nodes contain error status!"); } status = (Parents.Count(n => n.Status == (int)NodeStatus.Disable) == Parents.Count) ? (int)NodeStatus.Disable : (int)NodeStatus.None; } return(status); } catch (Exception err) { return((int)NodeStatus.Error); } }
public double[] Probabilities() { return(new double[Parents.Count()]); }