Exemplo n.º 1
0
        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 parentDataGridCollectionViewBase)
 {
     throw new NotImplementedException();
 }
        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 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;
        }