internal Group( GroupGeneratorNode node, CollectionViewGroup group, IList<GroupLevelDescription> groupLevelDescriptions, DataGridContext dataGridContext ) { if( node == null ) throw new ArgumentNullException( "node" ); if( group == null ) throw new ArgumentNullException( "group" ); if( groupLevelDescriptions == null ) throw new ArgumentNullException( "groupLevelDescriptions" ); if( dataGridContext == null ) throw new ArgumentNullException( "dataGridContext" ); m_generatorNode = node; m_collectionViewGroup = group; m_groupDescriptionsCollection = groupLevelDescriptions; m_dataGridContext = dataGridContext; //In case no late bingding is to happen, and if we already have everything to get the groupLevelDescription immediately, let's do! int level = m_generatorNode.Level; if( m_groupDescriptionsCollection.Count > level ) { m_groupLevelDescription = m_groupDescriptionsCollection[ level ]; } m_lateGroupLevelDescriptionBindingPerformed = false; m_generatorNode.TotalLeafCountChanged += OnTotalItemCountChanged; m_generatorNode.IsExpandedChanged += OnIsExpandedChanged; }
public override GroupConfiguration SelectGroupConfiguration( int groupLevel, CollectionViewGroup collectionViewGroup, System.ComponentModel.GroupDescription groupDescription ) { if( m_groupConfigurationSelectorItems.Count == 0 ) return base.SelectGroupConfiguration( groupLevel, collectionViewGroup, groupDescription ); string fieldName = string.Empty; DataGridGroupDescription dataGridGroupDescription = groupDescription as DataGridGroupDescription; if( dataGridGroupDescription != null ) { fieldName = dataGridGroupDescription.PropertyName; } else { PropertyGroupDescription propertyGroupDescription = groupDescription as PropertyGroupDescription; if( propertyGroupDescription != null ) { fieldName = propertyGroupDescription.PropertyName; } } if( String.IsNullOrEmpty( fieldName ) == true ) return base.SelectGroupConfiguration( groupLevel, collectionViewGroup, groupDescription ); FieldNameGroupConfigurationSelectorItem groupConfig = m_groupConfigurationSelectorItems.GetGroupConfigurationSelectorItem( fieldName ); if( groupConfig != null ) { return groupConfig.GroupConfiguration; } return base.SelectGroupConfiguration( groupLevel, collectionViewGroup, groupDescription ); }
private void CollapseOrExpandAll(CollectionViewGroup group, bool ifCollapse) { ReadOnlyObservableCollection<Object> groupSubGroups = null; if (group == null) { if (this.JobDataGrid.Items.Groups != null) { groupSubGroups = JobDataGrid.Items.Groups; } } else { groupSubGroups = group.Items; } if (groupSubGroups == null) return; foreach(CollectionViewGroup g in groupSubGroups) { if(ifCollapse) JobDataGrid.CollapseGroup(g); else JobDataGrid.ExpandGroup(g); //recursve call if(!g.IsBottomLevel) CollapseOrExpandAll(g,ifCollapse); } }
internal Group( GroupGeneratorNode node, CollectionViewGroup group, LateGroupLevelDescription groupLevelDescription, DataGridContext dataGridContext ) { if( node == null ) throw new ArgumentNullException( "node" ); if( group == null ) throw new ArgumentNullException( "group" ); if( groupLevelDescription == null ) throw new ArgumentNullException( "groupLevelDescription" ); if( dataGridContext == null ) throw new ArgumentNullException( "dataGridContext" ); m_collectionViewGroup = group; // Initialization is done through setters to register for events. this.DataGridContext = dataGridContext; this.GeneratorNode = node; this.GroupLevelDescription = groupLevelDescription; }
public GroupHeaderFooterItem( CollectionViewGroup collectionViewGroup, object template ) { if( !( template is DataTemplate ) && !( template is GroupHeaderFooterItemTemplate ) ) throw new ArgumentException( "A GroupHeaderFooterItem can only be created with a DataTemplate or VisibleWhenCollapsed objects.", "template" ); m_template = template; m_weakGroup = new WeakReference( collectionViewGroup ); }
public GroupGeneratorNode( CollectionViewGroup group, GeneratorNode parent, GroupConfiguration groupConfig ) : base( parent ) { Debug.Assert( group != null, "group cannot be null for GroupGeneratorNode" ); Debug.Assert( groupConfig != null ); m_group = group; m_groupConfig = groupConfig; }
public void Visit( DataGridContext sourceContext, System.Windows.Data.CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded, ref bool stopVisit ) { if( this.Group == null ) { GroupNamesTreeKey currentGroupKey = new GroupNamesTreeKey( namesTree ); if( currentGroupKey.Equals( m_groupNamesTreeKey ) == true ) this.Group = group; } }
private static string GetGroupIdentifier(CollectionViewGroup collectionViewGroup) { object groupId = collectionViewGroup.Name; if (groupId == null) return null; if (groupId is string) return (string)groupId; return groupId.ToString(); }
internal DataGridGroupInfo( GroupDescription groupDescription, CollectionViewGroup collectionViewGroup ) { if( groupDescription == null ) throw new ArgumentNullException( "groupDescription" ); if( collectionViewGroup == null ) throw new ArgumentNullException( "collectionViewGroup" ); this.GroupDescription = groupDescription; this.PropertyName = DataGridCollectionViewBase.GetPropertyNameFromGroupDescription( groupDescription ); this.Value = collectionViewGroup.Name; }
public static string FormViewGroupIdentifier(CollectionViewGroup collectionViewGroup, string sufix) { string formViewGroupIdentifier = collectionViewGroup.Name + sufix; CollectionViewGroup parentgroup = GetParent(collectionViewGroup); if (parentgroup == null) { return formViewGroupIdentifier; } return FormViewGroupIdentifier(parentgroup, StringForSufix + formViewGroupIdentifier); }
public void Visit(DataGridContext sourceContext, System.Windows.Data.CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded, ref bool stopVisit) { if (this.Group == null) { GroupNamesTreeKey currentGroupKey = new GroupNamesTreeKey(namesTree); if (currentGroupKey.Equals(m_groupNamesTreeKey) == true) { this.Group = group; } } }
public override GroupConfiguration SelectGroupConfiguration(int groupLevel, CollectionViewGroup collectionViewGroup, System.ComponentModel.GroupDescription groupDescription) { if (m_groupConfigurationSelectorItems.Count == 0) return base.SelectGroupConfiguration( groupLevel, collectionViewGroup, groupDescription ); LevelGroupConfigurationSelectorItem levelGroupConfig = m_groupConfigurationSelectorItems.GetGroupConfigurationSelectorItem( groupLevel ); if( levelGroupConfig != null ) { return levelGroupConfig.GroupConfiguration; } return base.SelectGroupConfiguration( groupLevel, collectionViewGroup, groupDescription ); }
public DataGridRowGroupInfo( CollectionViewGroup collectionViewGroup, Visibility visibility, int level, int slot, int lastSubItemSlot) { this.CollectionViewGroup = collectionViewGroup; this.Visibility = visibility; this.Level = level; this.Slot = slot; this.LastSubItemSlot = lastSubItemSlot; }
// Token: 0x06008330 RID: 33584 RVA: 0x00244BF8 File Offset: 0x00242DF8 int IComparer.Compare(object x, object y) { CollectionViewGroup collectionViewGroup = x as CollectionViewGroup; object a = ((collectionViewGroup != null) ? collectionViewGroup.Name : null) ?? x; collectionViewGroup = (y as CollectionViewGroup); object b = ((collectionViewGroup != null) ? collectionViewGroup.Name : null) ?? y; int num = Comparer.DefaultInvariant.Compare(a, b); if (this._direction != ListSortDirection.Ascending) { return(-num); } return(num); }
private readonly WeakReference m_dataGridControl; //null #endregion public GeneratorNode CreateGroupGeneratorNode( CollectionViewGroup collectionViewGroup, GeneratorNode parent, GeneratorNode previous, GeneratorNode next, GroupConfiguration groupConfig ) { Debug.Assert( collectionViewGroup != null, "collectionViewGroup cannot be null for CreateGroupGeneratorNode()" ); GroupGeneratorNode node = new GroupGeneratorNode( collectionViewGroup, parent, groupConfig ); if( previous != null ) { previous.Next = node; } node.Previous = previous; if( next != null ) { next.Previous = node; } node.Next = next; node.IsExpanded = groupConfig.InitiallyExpanded; if( !collectionViewGroup.IsBottomLevel ) { this.RegisterNodeCollectionChanged( ( INotifyCollectionChanged )collectionViewGroup.GetItems(), new NotifyCollectionChangedEventHandler( node.OnCollectionChanged ) ); node.CollectionChanged += m_groupsChangedHandler; } node.ExpansionStateChanged += m_expansionStateChangedHandler; node.IsExpandedChanging += m_isExpandedChangingHandler; node.IsExpandedChanged += m_isExpandedChangedHandler; node.AdjustItemCount( node.ItemCount ); node.BuildNamesTree(); return node; }
/// <summary> /// AutomationPeer for a group of items in a DataGrid /// </summary> public DataGridGroupItemAutomationPeer(CollectionViewGroup group, DataGrid dataGrid) : base(dataGrid) { if (group == null) { // throw new ElementNotAvailableException(); } if (dataGrid == null) { // throw new ElementNotAvailableException(); } _group = group; _dataGridAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(dataGrid); }
/// <summary> /// Returns the description of how to divide the given group into subgroups /// </summary> /// <param name="group">CollectionViewGroup to get group description from</param> /// <param name="level">The level of grouping</param> /// <returns>GroupDescription of how to divide the given group</returns> private GroupDescription GetGroupDescription(CollectionViewGroup group, int level) { GroupDescription result = null; if (group == this) { group = null; } if (result == null && this.GroupBySelector != null) { result = this.GroupBySelector(group, level); } if (result == null && level < this.GroupDescriptions.Count) { result = this.GroupDescriptions[level]; } return(result); }
void IDataGridContextVisitor.Visit(DataGridContext sourceContext, System.Windows.Data.CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded, ref bool stopVisit) { switch (m_status) { case SaveRestoreStateVisitorStatus.Saving: { this.SavingVisit(sourceContext, group, namesTree, groupLevel, isExpanded, isComputedExpanded); break; } case SaveRestoreStateVisitorStatus.Restoring: { this.RestoringVisit(sourceContext, group, namesTree, groupLevel, isExpanded, isComputedExpanded); break; } default: { throw new InvalidOperationException("An attempt was made to visit using a method other than the SaveRestoreStateVisitor's Save and Restore methods."); } } }
// should the given group be hidden? bool ShouldHide(CollectionViewGroup group) { return GroupStyle.HidesIfEmpty && // user asked to hide group.ItemCount == 0; // group is empty }
// create a group item for the given group DependencyObject ContainerForGroup(CollectionViewGroup group) { _generatesGroupItems = true; if (!ShouldHide(group)) { // normal group - link a new GroupItem GroupItem groupItem = new GroupItem(); LinkContainerToItem(groupItem, group); // create the generator groupItem.Generator = new ItemContainerGenerator(this, groupItem); return groupItem; } else { // hidden empty group - link a new EmptyGroupItem AddEmptyGroupItem(group); // but don't return it to layout return null; } }
internal bool IsGroupExpandedCore( CollectionViewGroup group, bool recurseDetails ) { if( group == null ) throw new ArgumentNullException( "group" ); this.EnsureNodeTreeCreated(); if( m_firstItem == null ) throw new DataGridInternalException(); Group uiGroup = this.GetGroupFromCollectionViewGroup( group ); if( uiGroup != null ) { return uiGroup.GeneratorNode.IsExpanded; } if( recurseDetails ) { //the group was not found in this generator, check in all the child generators for the group. foreach( KeyValuePair<object, List<DetailGeneratorNode>> itemToDetails in m_masterToDetails ) { foreach( DetailGeneratorNode detail in itemToDetails.Value ) { try { return detail.DetailGenerator.IsGroupExpandedCore( group, recurseDetails ); } catch( InvalidOperationException ) { //if the item is not found in the detail generator, it will throw //an invalid operation exception. If it doesn't throw, then it is //safe to return the return value of the function. //otherwise, suppress this exception as ultimately, the "root" function call will //throw if item is never found in itself or its details. } } } } throw new InvalidOperationException( "An attempt was made to consult the expansion state of a group that does not exist." ); }
public bool IsGroupExpanded( CollectionViewGroup group ) { return this.IsGroupExpandedCore( group, false ); }
internal bool ToggleGroupExpansionCore( CollectionViewGroup group, bool recurseDetails ) { if( this.Status == GeneratorStatus.GeneratingContainers ) { throw new InvalidOperationException( "An attempt was made to a toggle a group's expansion while the generator is busy generating items." ); } if( group == null ) throw new ArgumentNullException( "group" ); this.EnsureNodeTreeCreated(); if( m_firstItem == null ) throw new DataGridInternalException(); Group uiGroup = this.GetGroupFromCollectionViewGroup( group ); if( uiGroup != null ) { GroupGeneratorNode groupNode = uiGroup.GeneratorNode; groupNode.IsExpanded = !groupNode.IsExpanded; return true; } if( recurseDetails ) { //the item was not found in this generator's content... check all the detail generators foreach( KeyValuePair<object, List<DetailGeneratorNode>> itemToDetails in m_masterToDetails ) { foreach( DetailGeneratorNode detail in itemToDetails.Value ) { try { return detail.DetailGenerator.ToggleGroupExpansionCore( group, recurseDetails ); } catch( InvalidOperationException ) { //if the item is not found in the detail generator, it will throw //an invalid operation exception. If it doesn't throw, then it is //safe to return the return value of the function. //otherwise, suppress this exception as ultimately, the "root" function call will //throw if item is never found in itself or its details. } } } } return false; }
public bool CollapseGroup( CollectionViewGroup group ) { bool groupCollapsed = this.CollapseGroupCore( group, false ); if( !groupCollapsed ) throw new InvalidOperationException( "An attempt was made to collapse a group that does not exist." ); return groupCollapsed; }
// notification that a subgroup has become empty void OnSubgroupBecameEmpty(CollectionViewGroup group) { if (ShouldHide(group)) { GeneratorPosition position = PositionFromIndex(ItemsInternal.IndexOf(group)); // if the group is realized, un-realize it and notify layout if (position.Offset == 0 && position.Index >= 0) { // un-realize ((IItemContainerGenerator)this).Remove(position, 1); // inform layout as if the group just got removed if (ItemsChanged != null) { ItemsChanged(this, new ItemsChangedEventArgs(NotifyCollectionChangedAction.Remove, position, 1, 1)); } // create the placeholder AddEmptyGroupItem(group); } } }
public bool TryGetParentGroupFromItem( object item, bool recurseDetails, out CollectionViewGroup collectionViewGroup ) { collectionViewGroup = null; if( item == null ) return false; this.EnsureNodeTreeCreated(); if( m_startNode == null ) throw new DataGridInternalException(); //Invoke the helper that will check for the parent group within the local generator. if( this.TryGetParentGroupFromItemHelper( item, out collectionViewGroup ) ) { //if the item was found within the local generator, then return. return true; } //If the item was not in the local generator, continue with method. if( recurseDetails ) { //the item was not found in this generator's content... check all the detail generators foreach( KeyValuePair<object, List<DetailGeneratorNode>> itemToDetails in m_masterToDetails ) { foreach( DetailGeneratorNode detail in itemToDetails.Value ) { if( detail.DetailGenerator.TryGetParentGroupFromItem( item, recurseDetails, out collectionViewGroup ) ) { return true; } } } } return false; }
private bool TryGetParentGroupFromItemHelper( object item, out CollectionViewGroup collectionViewGroup ) { //This helper method is used to simplify previous code flow of the TryGetParentGroupFromItem method. collectionViewGroup = null; //----------------------------------------------- //1 - First check is to see of the item is a CVG. //----------------------------------------------- CollectionViewGroup groupItem = item as CollectionViewGroup; if( groupItem != null ) { Group group = this.GetGroupFromCollectionViewGroup( groupItem ); if( group != null ) { GroupGeneratorNode groupGeneratorNode = group.GeneratorNode; if( groupGeneratorNode.Parent == null ) { //no parent for speficied item. return true; } //if the nodeHelper was able to locate the content, use the nodeHelper's CurrentNode as the node for the item. collectionViewGroup = ( ( GroupGeneratorNode )groupGeneratorNode.Parent ).CollectionViewGroup; return true; } //item is a CVG, but is not present in the generator! return false; } //----------------------------------------------- //2 - Second check is to see if the item is already in the generated list //----------------------------------------------- //item might be in the "generated" list... much quicker to find-out if it is! //note: if the item belongs to a detail, then it will be excluded from the "fast" algo. int itemGenPosIndex = this.FindFirstGeneratedIndexForLocalItem( item ); if( itemGenPosIndex != -1 ) { //item was generated and was not from a DetailGeneratorNode if( m_genPosToNode[ itemGenPosIndex ].Parent == null ) { //no parent for speficied item. return true; } collectionViewGroup = ( ( GroupGeneratorNode )m_genPosToNode[ itemGenPosIndex ].Parent ).CollectionViewGroup; return true; } //----------------------------------------------- //3 - Third check is to check of the item is a GroupHeaderFooterItem //----------------------------------------------- if( item.GetType() == typeof( GroupHeaderFooterItem ) ) { GroupHeaderFooterItem groupHeaderFooterItem = ( GroupHeaderFooterItem )item; CollectionViewGroup parentGroup = groupHeaderFooterItem.Group; if( this.GetGroupFromCollectionViewGroup( parentGroup ) != null ) { //since the goal is the find the parentGroup from the item passed (which is a GroupHeader or GroupFooter), then the Group //is what I am looking for. collectionViewGroup = parentGroup; return true; } //Item was a GroupHeaderFooterItem but was not part of the genreator! return false; } //----------------------------------------------- //4 - Final Check //----------------------------------------------- //if the item was not generated, then try to find the item as is within the generator's content GeneratorNodeHelper finalNodeHelper = new GeneratorNodeHelper( m_startNode, 0, 0 ); if( finalNodeHelper.AbsoluteFindItem( item ) ) { //item was not generated but was part of this generator if( finalNodeHelper.CurrentNode.Parent == null ) { //no parent for speficied item. return true; } collectionViewGroup = ( ( GroupGeneratorNode )finalNodeHelper.CurrentNode.Parent ).CollectionViewGroup; return true; } else { return false; } //Default function behavior, if nobody else returned, then the function did not work as intended... as each "block" is supposed to return a value... throw new DataGridInternalException(); }
public Group GetGroupFromCollectionViewGroup( Group parentUIGroup, CollectionViewGroup collectionViewGroup ) { this.EnsureNodeTreeCreated(); GroupGeneratorNode groupGeneratorNode = null; if( m_groupNodeMappingCache.TryGetValue( collectionViewGroup, out groupGeneratorNode ) ) return groupGeneratorNode.UIGroup; return null; }
public Group GetGroupFromCollectionViewGroup( CollectionViewGroup collectionViewGroup ) { return this.GetGroupFromCollectionViewGroup( null, collectionViewGroup ); }
public GroupEnumerator(CollectionViewGroup root) { Groups = new List <object> (); Root = root; Reset(); }
// create an empty-group placeholder item void AddEmptyGroupItem(CollectionViewGroup group) { EmptyGroupItem emptyGroupItem = new EmptyGroupItem(); LinkContainerToItem(emptyGroupItem, group); emptyGroupItem.SetGenerator(new ItemContainerGenerator(this, emptyGroupItem)); // add it to the list of placeholder items (this keeps it from being GC'd) if (_emptyGroupItems == null) _emptyGroupItems = new ArrayList(); _emptyGroupItems.Add(emptyGroupItem); }
internal bool CollapseGroupCore( CollectionViewGroup group, bool recurseDetails ) { if( this.Status == GeneratorStatus.GeneratingContainers ) { throw new InvalidOperationException( "An attempt was made to collapse a group while the generator is busy generating items." ); } if( group == null ) throw new ArgumentNullException( "group" ); this.EnsureNodeTreeCreated(); if( m_firstItem == null ) throw new DataGridInternalException(); Group uiGroup = this.GetGroupFromCollectionViewGroup( group ); if( uiGroup != null ) { uiGroup.GeneratorNode.IsExpanded = false; return true; } if( recurseDetails ) { //the item was not found in this generator's content... check all the detail generators foreach( KeyValuePair<object, List<DetailGeneratorNode>> itemToDetails in m_masterToDetails ) { foreach( DetailGeneratorNode detail in itemToDetails.Value ) { // If the item is not found in the detail generator, it will return false; // The "public" function call will throw if item is never found in itself or its details. if( detail.DetailGenerator.CollapseGroupCore( group, recurseDetails ) ) return true; } } } return false; }
// notification that a subgroup has become non-empty void OnSubgroupBecameNonEmpty(EmptyGroupItem groupItem, CollectionViewGroup group) { // Discard placeholder container. UnlinkContainerFromItem(groupItem, group); if (_emptyGroupItems != null) _emptyGroupItems.Remove(groupItem); // inform layout as if the group just got added if (ItemsChanged != null) { GeneratorPosition position = PositionFromIndex(ItemsInternal.IndexOf(group)); ItemsChanged(this, new ItemsChangedEventArgs(NotifyCollectionChangedAction.Add, position, 1, 0)); } }
public bool ToggleGroupExpansion( CollectionViewGroup group ) { bool groupToggled = this.ToggleGroupExpansionCore( group, false ); if( !groupToggled ) throw new InvalidOperationException( "An attempt was made to toggle a group that does not exist." ); return groupToggled; }
public object[] GetNamesTreeFromGroup( CollectionViewGroup group ) { this.EnsureNodeTreeCreated(); Group uiGroup = this.GetGroupFromCollectionViewGroup( group ); if( uiGroup != null ) { return uiGroup.GeneratorNode.NamesTree; } return null; }
public void Visit(DataGridContext sourceContext, System.Windows.Data.CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded, ref bool stopVisit) { throw new NotSupportedException("Only DataGridContexts can be visited by this visitor."); }