internal AutoFilterValuesChangedEventArgs(
            DataGridDetailDescription detailDescription,
            DataGridItemPropertyBase itemProperty,
            IList autoFilterValues,
            NotifyCollectionChangedEventArgs collectionChangedEvent)
        {
            if (itemProperty == null)
            {
                throw new ArgumentNullException("itemProperty");
            }

            if (autoFilterValues == null)
            {
                throw new ArgumentNullException("autoFilterValues");
            }

            if (collectionChangedEvent == null)
            {
                throw new ArgumentNullException("collectionChangedEvent");
            }

            this.DetailDescription          = detailDescription;
            this.ItemProperty               = itemProperty;
            this.CollectionChangedEventArgs = collectionChangedEvent;
            this.AutoFilterValues           = autoFilterValues;
        }
 internal override DataGridCollectionViewBase CreateDetailDataGridCollectionViewBase(
     IEnumerable detailDataSource,
     DataGridDetailDescription parentDetailDescription,
     DataGridCollectionViewBase rootDataGridCollectionViewBase)
 {
     throw new NotImplementedException();
 }
 internal override DataGridCollectionViewBase CreateDetailDataGridCollectionViewBase(
   IEnumerable detailDataSource,
   DataGridDetailDescription parentDetailDescription,
   DataGridCollectionViewBase rootDataGridCollectionViewBase )
 {
   throw new NotImplementedException();
 }
Beispiel #4
0
        internal virtual void ApplyExtraPropertiesToView(DataGridCollectionViewBase currentView)
        {
            var currentViewItemProperties = currentView.ItemProperties;

            foreach (var itemProperty in m_itemProperties)
            {
                currentViewItemProperties[itemProperty.Name] = itemProperty;
            }

            var defaultCalculateDistinctValues = this.DefaultCalculateDistinctValues;

            foreach (var itemProperty in currentViewItemProperties)
            {
                // Set default value for CalculateDistinctValues if not explicitly set
                if (!itemProperty.IsCalculateDistinctValuesInitialized)
                {
                    itemProperty.CalculateDistinctValues = defaultCalculateDistinctValues;
                }
            }

            var autoCreateForeignKeyDescriptions = this.AutoCreateForeignKeyDescriptions;

            for (int i = 0; i < m_dataGridDetailDescriptions.Count; i++)
            {
                DataGridDetailDescription detailDescription = m_dataGridDetailDescriptions[i];

                // 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;
                }
            }
        }
    internal AutoFilterValuesChangedEventArgs(
      DataGridDetailDescription detailDescription,
      DataGridItemPropertyBase itemProperty,
      IList autoFilterValues,
      NotifyCollectionChangedEventArgs collectionChangedEvent )
    {
      if( itemProperty == null )
        throw new ArgumentNullException( "itemProperty" );

      if( autoFilterValues == null )
        throw new ArgumentNullException( "autoFilterValues" );

      if( collectionChangedEvent == null )
        throw new ArgumentNullException( "collectionChangedEvent" );

      this.DetailDescription = detailDescription;
      this.ItemProperty = itemProperty;
      this.CollectionChangedEventArgs = collectionChangedEvent;
      this.AutoFilterValues = autoFilterValues;
    }
        internal virtual void OnDetailDescriptionsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // Set the AutoFilterValuesChanged event for each
            // newly added DataGridDetailDescription added to
            // collection
            int newItemsCount = (e.NewItems != null)
       ? e.NewItems.Count
       : 0;

            int oldItemsCount = (e.OldItems != null)
      ? e.OldItems.Count
      : 0;

            for (int i = 0; i < oldItemsCount; i++)
            {
                DataGridDetailDescription description = e.OldItems[i] as DataGridDetailDescription;

                if (description == null)
                {
                    continue;
                }

                description.UnregisterAllAutoFilterValuesChangedEvent();
            }

            for (int i = 0; i < newItemsCount; i++)
            {
                DataGridDetailDescription description = e.NewItems[i] as DataGridDetailDescription;

                if (description == null)
                {
                    continue;
                }

                description.DetailDescriptionAutoFilterValuesChanged = this.RaiseDetailDescriptionAutoFilterValuesChangedEvent;
            }
        }
 internal abstract DataGridCollectionViewBase CreateDetailDataGridCollectionViewBase(
   IEnumerable detailDataSource,
   DataGridDetailDescription parentDetailDescription,
   DataGridCollectionViewBase rootDataGridCollectionViewBase );
    internal virtual void CreateDefaultCollections( DataGridDetailDescription parentDetailDescription )
    {
      Debug.Assert( parentDetailDescription == null || this.CanHaveDetails );

      m_sortDescriptions = ( parentDetailDescription == null ) ? new DataGridSortDescriptionCollection() :
        parentDetailDescription.SortDescriptions as DataGridSortDescriptionCollection;

      m_groupDescriptions = ( parentDetailDescription == null ) ? new GroupDescriptionCollection() :
        parentDetailDescription.GroupDescriptions;
    }
    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 void SynchronizeWithDetailDescription( DataGridDetailDescription detailDescription )
    {
      if( detailDescription != m_detailDescription )
      {
        this.DetachFromDetailDescription();

        m_shouldCreateColumns = true;
        m_detailDescription = detailDescription;

        DataGridSortDescriptionCollection dataGridSortDescriptionCollection = null;

        if( detailDescription != null )
        {
          //register to the collectionchanged of the DataGridDetailDescription collection of the detailDescription matching this one.
          dataGridSortDescriptionCollection = detailDescription.DataGridSortDescriptions;
          m_groupDescriptions = detailDescription.GroupDescriptions;

          CollectionChangedEventManager.AddListener( detailDescription.ItemProperties, this );
          CollectionChangedEventManager.AddListener( detailDescription.DetailDescriptions, this );
        }
        else
        {
          dataGridSortDescriptionCollection = new DataGridSortDescriptionCollection();
          m_groupDescriptions = new GroupDescriptionCollection();
        }

        m_sortDescriptions = dataGridSortDescriptionCollection;
        m_sortDescriptionsSyncContext = null; //clear it, if it was ever set!


        //This update is required since there might be some columns in the Columns collection after the XAML parsing of the DetailConfiguration
        DataGridContext.SynchronizeSortProperties( dataGridSortDescriptionCollection.SyncContext, m_sortDescriptions, this.Columns );

        //This update is required since we want the GroupLevelDescriptions to be created if DetailConfiguration in XAML
        //contains GroupDescriptions
        DataGridContext.UpdateGroupLevelDescriptions( this.GroupLevelDescriptions, new NotifyCollectionChangedEventArgs( NotifyCollectionChangedAction.Reset ), this.GroupDescriptions, this.Columns );

        CollectionChangedEventManager.AddListener( m_sortDescriptions, this );
        CollectionChangedEventManager.AddListener( m_groupDescriptions, this );

        if( detailDescription != null )
        {
          if( this.ReadLocalValue( DetailConfiguration.TitleProperty ) == DependencyProperty.UnsetValue )
          {
            if( detailDescription.Title == null )
            {
              this.Title = detailDescription.RelationName;
            }
            else
            {
              this.Title = detailDescription.Title;
            }
          }

          if( ( this.ReadLocalValue( DetailConfiguration.TitleTemplateProperty ) == DependencyProperty.UnsetValue )
            && ( detailDescription.TitleTemplate != null ) )
          {
            this.TitleTemplate = detailDescription.TitleTemplate;
          }

          DetailConfiguration.SynchronizeDetailConfigurations(
            detailDescription.DetailDescriptions,
            this.DetailConfigurations,
            this.AutoCreateDetailConfigurations,
            this.AutoCreateForeignKeyConfigurations,
            this.AutoRemoveColumnsAndDetailConfigurations );
        }
      }

      if( detailDescription != null )
      {
        ForeignKeyConfiguration.UpdateColumnsForeignKeyConfigurationsFromDataGridCollectionView(
          this.Columns.FieldNameToColumnDictionary,
          detailDescription.ItemProperties,
          this.AutoCreateForeignKeyConfigurations );
      }
    }
        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 void SetSource( DataGridControl dataGridControl, DataGridDetailDescription detailDescription )
      {
        if( ( dataGridControl == null ) || ( detailDescription == null ) || ( !dataGridControl.AreDetailsFlatten ) )
        {
          this.Source = null;
        }
        else
        {
          var map = this.Source as ItemPropertyNameMap;
          var itemProperties = detailDescription.ItemProperties;

          if( ( map == null ) || ( map.ItemProperties != detailDescription.ItemProperties ) )
          {
            this.Source = new ItemPropertyNameMap( itemProperties );
          }
        }
      }