/// <summary> /// Internal use only. /// </summary> /// <param name="name"></param> /// <param name="level"></param> /// <param name="parent"></param> public CollectionViewGroupNode(object name, int level, CollectionViewGroupNode parent) : base(name) { _parent = parent; _level = level; _root = GetRoot(); }
private CollectionViewGroupNode GetGroupNode(int level, object name) { var node = this.Items.Cast <CollectionViewGroupNode>().Where(n => object.Equals(n.Name, name)).FirstOrDefault(); if (node == null) { node = new CollectionViewGroupNode(name, level, this); AddItem(node); } return(node); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="level"></param> /// <param name="parent"></param> protected void AddItemToGroup(object item, int level, CollectionViewGroupNode parent) { if (IsBottomLevel) { AddItem(item); } else { var gd = _root.GroupDescriptions[level]; var groupName = gd.GroupNameFromItem(item, level, System.Globalization.CultureInfo.CurrentCulture); int newLevel = level + 1; var node = GetGroupNode(newLevel, groupName); node.AddItemToGroup(item, newLevel, this); } }
bool IEnumerator.MoveNext() { while ((_subEnum == null) || !_subEnum.MoveNext()) { _index++; if (_index >= _group.Items.Count) { return(false); } CollectionViewGroupNode node = _group.Items[_index] as CollectionViewGroupNode; if (node == null) { _current = _group.Items[_index]; _subEnum = null; return(true); } _subEnum = node.GetLeafEnumerator(); } _current = _subEnum.Current; return(true); }
public LeafEnumerator(CollectionViewGroupNode group) { _group = group; DoReset(); }
private CollectionViewGroupNode GetGroupNode(int level, object name) { var node = this.Items.Cast<CollectionViewGroupNode>().Where(n => object.Equals(n.Name, name)).FirstOrDefault(); if (node == null) { node = new CollectionViewGroupNode(name, level, this); AddItem(node); } return node; }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="level"></param> /// <param name="parent"></param> protected void RemoveItemFromGroup(object item, int level, CollectionViewGroupNode parent) { if (IsBottomLevel) { RemoveItem(item); RemoveGroupIfEmpty(); } else { var gd = _root.GroupDescriptions[level]; var groupName = gd.GroupNameFromItem(item, level, System.Globalization.CultureInfo.CurrentCulture); int newLevel = level + 1; var node = GetGroupNode(newLevel, groupName); node.RemoveItemFromGroup(item, newLevel, this); } }