internal override DataGridCollectionViewBase CreateDetailDataGridCollectionViewBase( IEnumerable detailDataSource, DataGridDetailDescription parentDetailDescription, DataGridCollectionViewBase rootDataGridCollectionViewBase ) { throw new NotImplementedException(); }
public DataGridItemEventArgs( DataGridCollectionViewBase collectionView, object item ) { m_collectionView = collectionView; m_item = item; }
public DataGridItemCancelEventArgs( DataGridCollectionViewBase collectionView, object item, bool cancel ) : base( collectionView, item ) { m_cancel = cancel; }
public DataGridCreatingNewItemEventArgs( DataGridCollectionViewBase collectionView, object newItem, bool cancel ) : base( cancel ) { m_collectionView = collectionView; m_newItem = newItem; }
public static void RemoveListener( DataGridCollectionViewBase source, IWeakEventListener listener ) { if( source == null ) throw new ArgumentNullException( "source" ); if( listener == null ) throw new ArgumentNullException( "listener" ); CurrentManager.ProtectedRemoveListener( source, listener ); }
protected internal override IEnumerable GetDetailsForParentItem( DataGridCollectionViewBase parentCollectionView, object parentItem ) { IEnumerable enumerable = parentItem as IEnumerable; if (enumerable == null) return null; this.Seal(); return enumerable; }
public DeferredOperationManager( DataGridCollectionViewBase collectionViewToUpdate, Dispatcher dispatcher, bool postPendingRefreshWithoutDispatching ) { m_collectionViewToUpdate = collectionViewToUpdate; if( postPendingRefreshWithoutDispatching ) this.Add( new DeferredOperation( DeferredOperation.DeferredOperationAction.Refresh, -1, null ) ); m_dispatcher = dispatcher; }
protected internal override IEnumerable GetDetailsForParentItem( DataGridCollectionViewBase parentCollectionView, object parentItem ) { IListSource listSource = parentItem as IListSource; if( listSource == null ) return null; this.Seal(); return listSource.GetList(); }
internal DeferredOperationManager( DataGridCollectionViewBase collectionView, Dispatcher dispatcher, bool postPendingRefreshWithoutDispatching ) { m_collectionView = collectionView; m_deferredOperations = new List<DeferredOperation>( 1000 ); m_invalidatedGroups = new HashSet<DataGridCollectionViewGroup>(); if( postPendingRefreshWithoutDispatching ) { this.Add( new DeferredOperation( DeferredOperation.DeferredOperationAction.Refresh, -1, null ) ); } m_dispatcher = dispatcher; }
protected internal override IEnumerable GetDetailsForParentItem( DataGridCollectionViewBase parentCollectionView, object parentItem ) { EntityObject entityObject = parentItem as EntityObject; if( entityObject == null ) return null; // Even if EntityObject is not in a loadable state, we must still return the IList // so that the ItemProperties can be extracted based on the elements type. bool entityObjectLoadable = ItemsSourceHelper.IsEntityObjectLoadable( entityObject ); // We let the user take charge of handling the details. QueryEntityDetailsEventArgs args = new QueryEntityDetailsEventArgs( entityObject ); if( entityObjectLoadable ) this.OnQueryDetails( args ); // The parentItem must implement IEntityWithRelationships Type parentItemType = parentItem.GetType(); if( typeof( IEntityWithRelationships ).IsAssignableFrom( parentItemType ) ) { // Since the relationship was based on the the property // name, we must find that property using reflection. PropertyInfo propertyInfo = parentItemType.GetProperty( this.RelationName ); if( propertyInfo != null ) { RelatedEnd relatedEnd = propertyInfo.GetValue( parentItem, null ) as RelatedEnd; if( relatedEnd != null ) { // Make sure that the details are loaded // except if the user already handled it. if( !relatedEnd.IsLoaded && !args.Handled && entityObjectLoadable ) { relatedEnd.Load(); } IListSource listSource = relatedEnd as IListSource; // Returns an IList to have proper change notification events. if( listSource != null ) return listSource.GetList(); } } } return null; }
protected internal override void Initialize( DataGridCollectionViewBase parentCollectionView ) { base.Initialize( parentCollectionView ); if( this.DataRelation != null ) return; string relationName = this.RelationName; if( string.IsNullOrEmpty( relationName ) ) throw new InvalidOperationException( "An attempt was made to initialize a DataRelationDetailDescription whose RelationName property has not been set." ); this.DataRelation = this.FindDataRelation( parentCollectionView, relationName ); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// protected override IEnumerable GetDetailsForParentItem(DataGridCollectionViewBase parentCollectionView, object parentItem) { Debug.Assert(parentItem is SelectReportWrapper); IEnumerable subReports = null; if (null == parentItem) subReports = new List<SelectReportWrapper>(); else { _report = parentItem as SelectReportWrapper; subReports = _report.SubReportWrappers; } return subReports; }
protected internal override IEnumerable GetDetailsForParentItem( DataGridCollectionViewBase parentCollectionView, object parentItem ) { if( this.DataRelation == null ) throw new InvalidOperationException( "An attempt was made to obtain the details of a DataRelationDetailDescription object whose DataRelation property has not been set." ); this.Seal(); System.Data.DataRow dataRow = parentItem as System.Data.DataRow; DataRowView dataRowView; if( dataRow != null ) { int rawIndex = parentCollectionView.IndexOfSourceItem( dataRow ); DataView dataView = parentCollectionView.SourceCollection as DataView; if( dataView == null ) return null; dataRowView = dataView[ rawIndex ]; } else { dataRowView = parentItem as DataRowView; } if( dataRowView == null ) return null; if( !m_userAssignedDataRelation ) { if( m_dataRelation.ParentTable != dataRowView.Row.Table ) { m_dataRelation = this.FindDataRelation( parentCollectionView, this.RelationName ); } } return dataRowView.CreateChildView( m_dataRelation ); }
internal DataGridCollectionViewBase( IEnumerable collection, DataGridDetailDescription parentDetailDescription, DataGridCollectionViewBase rootDataGridCollectionViewBase ) : this() { if( !this.CanHaveDetails ) throw new InvalidOperationException( "An attempt was made to provide a detail description for a source that cannot have details." ); if( parentDetailDescription == null ) throw new ArgumentNullException( "parentDetailDescription" ); this.AutoCreateDetailDescriptions = parentDetailDescription.AutoCreateDetailDescriptions; this.AutoCreateItemProperties = parentDetailDescription.AutoCreateItemProperties; this.AutoCreateForeignKeyDescriptions = parentDetailDescription.AutoCreateForeignKeyDescriptions; m_parentDetailDescription = parentDetailDescription; m_rootDataGridCollectionViewBase = rootDataGridCollectionViewBase; Type itemType; itemType = ItemsSourceHelper.GetItemTypeFromEnumeration( collection ); if( itemType == null ) itemType = typeof( object ); this.InitializeFromExternalDeclaration( collection, itemType ); // This is required in the Master/Detail scheme of things! this.ForceRefresh( false, true, false ); }
private DataRelation FindDataRelation( DataGridCollectionViewBase parentCollectionView, string relationName ) { DataView view = parentCollectionView.SourceCollection as DataView; if( view == null ) throw new InvalidOperationException( "An attempt was made to initialize a DataRelationDetailDescription whose data source is not a DataView." ); foreach( DataRelation relation in view.Table.ChildRelations ) { if( relation.RelationName == relationName ) { return relation; } } throw new InvalidOperationException( "An attempt was made to initialize a DataRelationDetailDescription whose data source does not contain a DataRelation corresponding to the specified name." ); }
internal virtual void ApplyExtraPropertiesToView( DataGridCollectionViewBase currentView ) { DataGridItemPropertyCollection currentViewItemProperties = currentView.ItemProperties; int count = m_itemProperties.Count; for( int i = 0; i < count; i++ ) { DataGridItemPropertyBase itemProperty = m_itemProperties[ i ]; int index = currentViewItemProperties.IndexOf( itemProperty.Name ); if( index == -1 ) { currentViewItemProperties.Add( itemProperty ); } else { currentViewItemProperties[ index ] = itemProperty; } } count = currentView.ItemProperties.Count; bool defaultCalculateDistinctValues = this.DefaultCalculateDistinctValues; for( int i = 0; i < count; i++ ) { DataGridItemPropertyBase dataGridItemProperty = currentView.ItemProperties[ i ]; // Set default value for CalculateDistinctValues if not explicitly set if( !dataGridItemProperty.IsCalculateDistinctValuesInitialized ) dataGridItemProperty.CalculateDistinctValues = defaultCalculateDistinctValues; } count = m_dataGridDetailDescriptions.Count; bool autoCreateForeignKeyDescriptions = this.AutoCreateForeignKeyDescriptions; DataGridDetailDescriptionCollection currentViewDetailDescriptions = currentView.DetailDescriptions; for( int i = 0; i < count; i++ ) { DataGridDetailDescription detailDescription = m_dataGridDetailDescriptions[ i ]; int index = currentViewDetailDescriptions.IndexOf( detailDescription.RelationName ); if( index == -1 ) { currentViewDetailDescriptions.Add( detailDescription ); } else { currentViewDetailDescriptions[ index ] = detailDescription; } // We assume we want to auto-create ForeignKeyDescriptions for DetailDescriptions // if this.AutoCreateForeignKeyDescriptions is true and it was auto-created if( detailDescription.IsAutoCreated ) { detailDescription.AutoCreateForeignKeyDescriptions = autoCreateForeignKeyDescriptions; } } currentView.AutoFilterMode = this.AutoFilterMode; currentView.DistinctValuesConstraint = this.DistinctValuesConstraint; currentView.DistinctValuesUpdateMode = this.DistinctValuesUpdateMode; currentView.FilterCriteriaMode = this.FilterCriteriaMode; }
internal abstract DataGridCollectionViewBase CreateDetailDataGridCollectionViewBase( IEnumerable detailDataSource, DataGridDetailDescription parentDetailDescription, DataGridCollectionViewBase rootDataGridCollectionViewBase );
protected internal abstract IEnumerable GetDetailsForParentItem( DataGridCollectionViewBase parentCollectionView, object parentItem );
public DataGridItemRemovedEventArgs( DataGridCollectionViewBase collectionView, object item, int index ) : base( collectionView, item ) { m_index = index; }
private static Dictionary<string, FieldDescriptor> GetFieldsForDataGridCollectionViewBase( DataGridCollectionViewBase dataGridCollectionViewBase, DataGridItemPropertyCollection itemProperties ) { int fieldCount = itemProperties.Count; Dictionary<string, FieldDescriptor> fieldDescriptors = new Dictionary<string, FieldDescriptor>( fieldCount ); for( int i = 0; i < fieldCount; i++ ) { DataGridItemPropertyBase itemProperty = itemProperties[ i ]; fieldDescriptors[ itemProperty.Name ] = ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ); } return fieldDescriptors; }
internal override void ApplyExtraPropertiesToView( DataGridCollectionViewBase currentView ) { base.ApplyExtraPropertiesToView( currentView ); DataGridCollectionView dataGridCollectionView = currentView as DataGridCollectionView; dataGridCollectionView.StatFunctions.Clear(); foreach( var statFunction in m_statFunctions ) { dataGridCollectionView.StatFunctions.Add( statFunction ); } dataGridCollectionView.UpdateChangedPropertyStatsOnly = this.UpdateChangedPropertyStatsOnly; }
protected internal override void Initialize( DataGridCollectionViewBase parentCollectionView ) { base.Initialize( parentCollectionView ); if( this.PropertyDescriptor != null ) return; string relationName = this.RelationName; if( String.IsNullOrEmpty( relationName ) == true ) throw new InvalidOperationException( "An attempt was made to initialize a PropertyDetailDescription whose Name property has not been set." ); foreach( DataGridDetailDescription detailDescription in parentCollectionView.DetailDescriptions.DefaultDetailDescriptions ) { PropertyDetailDescription propertyDetailDescription = detailDescription as PropertyDetailDescription; if( propertyDetailDescription != null ) { if( propertyDetailDescription.RelationName == relationName ) { this.PropertyDescriptor = propertyDetailDescription.PropertyDescriptor; return; } } } // The DetailDescription for RelationName was not found in DefaultDetailDescription // and may not have the PropertyDetailDescriptionAttribute if( this.PropertyDescriptor == null ) { PropertyDescriptor relationDescriptor = null; IEnumerable enumeration = parentCollectionView as IEnumerable; if( enumeration != null ) { // Try to get it from the first item in the DataGridCollectionView object firstItem = ItemsSourceHelper.GetFirstItemByEnumerable( enumeration ); if( firstItem != null ) { relationDescriptor = this.GetPropertyDescriptorFromFirstItem( firstItem ); if( relationDescriptor != null ) { this.PropertyDescriptor = relationDescriptor; return; } } } // If the list is empty, check if the SourceCollection is ITypedList ITypedList iTypedList = parentCollectionView.SourceCollection as ITypedList; if( iTypedList != null ) { relationDescriptor = this.GetPropertyDescriptorFromITypedList( iTypedList ); if( relationDescriptor != null ) { this.PropertyDescriptor = relationDescriptor; return; } } } throw new InvalidOperationException( "An attempt was made to initialize a PropertyDetailDescription whose data source does not contain a property that corresponds to the specified relation name." ); }
protected internal override IEnumerable GetDetailsForParentItem( DataGridCollectionViewBase parentCollectionView, object parentItem ) { if( this.PropertyDescriptor == null ) throw new InvalidOperationException( "An attempt was made to obtain details of a PropertyDetailDescription object whose PropertyDescriptor property has not been set." ); this.Seal(); object value = this.PropertyDescriptor.GetValue( parentItem ); if( value == null ) return null; IEnumerable enumeration = value as IEnumerable; if( enumeration == null ) { IListSource listSource = value as IListSource; if( listSource != null ) { enumeration = listSource.GetList(); } } return enumeration; }
public DeferRefreshHelper( DataGridCollectionViewBase collectionView ) { m_collectionView = collectionView; collectionView.m_deferRefreshCount++; }
public DeferCurrencyEventHelper( DataGridCollectionViewBase collectionView ) { m_collectionView = collectionView; m_oldCurrentItem = m_collectionView.CurrentItem; m_oldCurrentPosition = m_collectionView.CurrentPosition; m_oldIsCurrentAfterLast = m_collectionView.IsCurrentAfterLast; m_oldIsCurrentBeforeFirst = m_collectionView.IsCurrentBeforeFirst; m_collectionView.m_deferCurrencyEventCount++; }
internal void InternalInitialize( DataGridCollectionViewBase parentCollectionView ) { if( string.IsNullOrEmpty( this.RelationName ) ) throw new InvalidOperationException( "An attempt was made to initialize a detail description that does not have a relation name." ); this.Initialize( parentCollectionView ); }
private void EnsureDataGridCollectionViewBase() { try { DataGridCollectionViewBase view = this.EnsureDataGridCollectionViewBaseCore(); if( view == null ) { if( m_currentView != null ) { m_currentView.ParentCollectionViewSourceBase = null; m_currentView = null; } } if( m_currentView != view ) { DataGridCollectionViewBase oldView = m_currentView; m_currentView = view; if( ( oldView != null ) && ( oldView.ItemProperties != null ) ) { // Ensure to unregister the ItemsProperties collection from // events of the ItemProperties it contains to avoid memory leaks. // The ItemProperties are reused when a new DataGridCollectionViewBase // is generated by the DataGridCollectionViewBaseDataProvider and // the ItemProperties collection of this new DataGridCollectionViewBase // will also register to those events. // We can safely unregister from those here wince the old // DataGridCollectionViewBase will not be reused anywhere else. oldView.ItemProperties.UnregisterDataGridItemPropertiesEvents(); } } if( m_currentView != null ) m_currentView.ParentCollectionViewSourceBase = m_parentSource; } catch { m_currentView.ParentCollectionViewSourceBase = null; m_currentView = null; throw; } }
internal override void ApplyExtraPropertiesToView( DataGridCollectionViewBase currentView ) { base.ApplyExtraPropertiesToView( currentView ); DataGridVirtualizingCollectionViewBase dataGridVirtualizingCollectionView = currentView as DataGridVirtualizingCollectionViewBase; dataGridVirtualizingCollectionView.PreemptivePageQueryRatio = this.PreemptivePageQueryRatio; dataGridVirtualizingCollectionView.CommitMode = this.CommitMode; }
internal override void ApplyExtraPropertiesToView( DataGridCollectionViewBase currentView ) { base.ApplyExtraPropertiesToView( currentView ); DataGridCollectionView dataGridCollectionView = currentView as DataGridCollectionView; dataGridCollectionView.StatFunctions.Clear(); int count = m_statFunctions.Count; for( int i = 0; i < count; i++ ) { dataGridCollectionView.StatFunctions.Add( m_statFunctions[ i ] ); } dataGridCollectionView.UpdateChangedPropertyStatsOnly = this.UpdateChangedPropertyStatsOnly; }
protected internal virtual void Initialize( DataGridCollectionViewBase parentCollectionView ) { }