/// <summary> /// Adds the group to the diagram after validating it. /// </summary> /// <param name="group">A group instance.</param> public void AddGroup(GroupModel group) { if (group.Children.Length < 2) { throw new ArgumentException("Number of nodes must be >= 2"); } var layers = group.Children.Select(n => n.Layer).Distinct(); if (layers.Count() > 1) { throw new InvalidOperationException("Cannot group nodes with different layers"); } if (layers.First() == RenderLayer.SVG) { throw new InvalidOperationException("SVG groups aren't implemented yet"); } foreach (var child in group.Children) { if (child is GroupModel g) { _groups.Remove(g); } else { _nodes.Remove(child); } } _groups.Add(group); GroupAdded?.Invoke(group); Refresh(); }
/// <summary> /// Adds the group to the diagram after validating it. /// </summary> /// <param name="group">A group instance.</param> public void AddGroup(GroupModel group) { if (group.Children.Count > 0) { var layers = group.Children.Select(n => n.Layer).Distinct(); if (layers.Count() > 1) { throw new InvalidOperationException("Cannot group nodes with different layers"); } if (layers.First() == RenderLayer.SVG) { throw new InvalidOperationException("SVG groups aren't implemented yet"); } } foreach (var child in group.Children) { if (child is NodeModel node && !Nodes.Contains(node)) { throw new Exception("One of the nodes isn't in the diagram. Make sure to add all the nodes before creating the group."); } } _groups.Add(group); GroupAdded?.Invoke(group); Refresh(); }
public Group Group(params NodeModel[] nodes) { if (nodes == null || nodes.Length == 0) { throw new ArgumentException($"Null or empty nodes array"); } if (nodes.Select(n => n.Layer).Distinct().Count() > 1) { throw new InvalidOperationException("Cannot group nodes with different layers"); } if (nodes.Any(n => n.Group != null)) { throw new InvalidOperationException("Cannot group nodes that already belong to another group"); } var group = new Group(nodes[0].Layer); foreach (var node in nodes) { node.Group = group; group.AddNode(node); node.Refresh(); } _groups.Add(group); GroupAdded?.Invoke(group); return(group); }
private Group GetOrAddGroup(string name) { Group group = null; if (!groups.TryGetValue(name, out group)) { group = new Group(name, this); groups.Add(group.Name, group); GroupAdded?.Invoke(group); } return(group); }
public void addMovementSequence(String groupName, MovementSequenceInfo info) { MovementSequenceGroup group = currentSequenceSet.getGroup(groupName); if (group == null) { group = new MovementSequenceGroup(groupName); currentSequenceSet.addGroup(group); if (GroupAdded != null) { GroupAdded.Invoke(this, group); } } group.addSequence(info); if (SequenceAdded != null) { SequenceAdded.Invoke(this, group, info); } }
private ButtonGridGroup findGroup(String group) { ButtonGridGroup addGroup = null; foreach (ButtonGridGroup groupIter in groups) { if (groupIter.Name == group) { addGroup = groupIter; break; } } if (addGroup == null) { addGroup = new ButtonGridGroup(group, this); groups.Add(addGroup); if (GroupAdded != null) { GroupAdded.Invoke(this, addGroup.Name); } } return(addGroup); }
public GroupModel Group(params NodeModel[] nodes) { if (nodes.Length < 2) { throw new ArgumentException("Number of nodes must be >= 2"); } var layers = nodes.Select(n => n.Layer).Distinct(); if (layers.Count() > 1) { throw new InvalidOperationException("Cannot group nodes with different layers"); } if (layers.First() == RenderLayer.SVG) { throw new InvalidOperationException("SVG groups aren't imeplemtend yet"); } if (nodes.Any(n => n.Group != null)) { throw new InvalidOperationException("Cannot group nodes that already belong to another group"); } var group = new GroupModel(this, nodes); foreach (var node in nodes) { _nodes.Remove(node); } _groups.Add(group); GroupAdded?.Invoke(group); Refresh(); return(group); }
private static void OnGroupAdded(CommandGroup obj) { GroupAdded?.Invoke(obj); }