internal virtual void OnItemPropertiesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Replace:
                Debug.Assert(false, "The replace of an ItemProperty is not supported.");
                break;

            case NotifyCollectionChangedAction.Remove:

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

                for (int i = 0; i < oldItemsCount; i++)
                {
                    DataGridItemPropertyBase dataGridItemProperty = e.OldItems[i] as DataGridItemPropertyBase;
                    Debug.Assert(dataGridItemProperty != null);

                    this.UnregisterAutoFilterValuesChangedEvent(dataGridItemProperty.Name);
                }
                break;

            case NotifyCollectionChangedAction.Reset:

                this.UnregisterAllAutoFilterValuesChangedEvent();
                break;
            }
        }
        internal static DataGridItemPropertyRoute Combine(DataGridItemPropertyBase itemProperty, DataGridItemPropertyRoute ancestors)
        {
            if (itemProperty == null)
            {
                return(ancestors);
            }

            if (ancestors == null)
            {
                return(DataGridItemPropertyRoute.Create(itemProperty));
            }

            var collection = itemProperty.ContainingCollection;

            if (collection == null)
            {
                throw new InvalidOperationException();
            }

            if (collection.Owner != ancestors.Current)
            {
                throw new InvalidOperationException();
            }

            return(new DataGridItemPropertyRoute(itemProperty, ancestors));
        }
        private void OnAutoFilterValuesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (this.AutoFilterMode == AutoFilterMode.None)
            {
                return;
            }

            ObservableHashList hashList = sender as ObservableHashList;

            if (hashList == null)
            {
                return;
            }

            string fieldName = m_registeredAutoFilterValuesToFieldNames[hashList];

            if (string.IsNullOrEmpty(fieldName))
            {
                return;
            }

            DataGridItemPropertyBase itemProperty = this.ItemProperties[fieldName];

            if (itemProperty == null)
            {
                return;
            }

            this.DetailDescriptionAutoFilterValuesChanged(new AutoFilterValuesChangedEventArgs(this, itemProperty, hashList, e));
        }
示例#4
0
        protected DataGridItemPropertyBase(DataGridItemPropertyBase template)
            : this()
        {
            m_name     = template.m_name;
            m_dataType = template.m_dataType;
            m_title    = template.m_title;
            m_synonym  = template.m_synonym;
            m_flags[DataGridItemPropertyBaseFlags.IsReadOnly] = template.m_flags[DataGridItemPropertyBaseFlags.IsReadOnly];
            m_flags[DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertionSet] = template.m_flags[DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertionSet];
            m_flags[DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertion]    = template.m_flags[DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertion];
            m_flags[DataGridItemPropertyBaseFlags.IsASubRelationshipSet]             = template.m_flags[DataGridItemPropertyBaseFlags.IsASubRelationshipSet];
            m_flags[DataGridItemPropertyBaseFlags.IsASubRelationship]      = template.m_flags[DataGridItemPropertyBaseFlags.IsASubRelationship];
            m_flags[DataGridItemPropertyBaseFlags.IsBrowsable]             = template.m_flags[DataGridItemPropertyBaseFlags.IsBrowsable];
            m_flags[DataGridItemPropertyBaseFlags.CalculateDistinctValues] = template.m_flags[DataGridItemPropertyBaseFlags.CalculateDistinctValues];
            m_converter                         = template.m_converter;
            m_converterCulture                  = template.m_converterCulture;
            m_converterParameter                = template.m_converterParameter;
            this.FilterCriterion                = template.m_filterCriterion;
            m_foreignKeyDescription             = template.m_foreignKeyDescription;
            m_maxDistinctValues                 = template.m_maxDistinctValues;
            m_sortComparer                      = template.m_sortComparer;
            this.DistinctValuesEqualityComparer = template.DistinctValuesEqualityComparer;
            this.DistinctValuesSortComparer     = template.DistinctValuesSortComparer;

            // FilterCriterionChanged is not cloned since only used after the clone occurs
            this.PropertyChanged    += template.PropertyChanged;
            this.QueryDistinctValue += template.m_queryDistinctValue;
        }
 public SortDescriptionInfo(
   DataGridItemPropertyBase property,
   ListSortDirection direction )
 {
   m_property = property;
   m_direction = direction;
 }
        private void UnmapItemProperties(DataGridItemPropertyBase masterItemProperty, DataGridItemPropertyBase detailItemProperty, bool recursive)
        {
            if ((masterItemProperty == null) || (detailItemProperty == null))
            {
                return;
            }

            DataGridItemPropertyBase mappedItemProperty;

            if (!m_masterToDetail.TryGetValue(masterItemProperty, out mappedItemProperty) || (mappedItemProperty != detailItemProperty))
            {
                throw new InvalidOperationException();
            }

            if (!m_detailToMaster.TryGetValue(detailItemProperty, out mappedItemProperty) || (mappedItemProperty != masterItemProperty))
            {
                throw new InvalidOperationException();
            }

            m_masterToDetail.Remove(masterItemProperty);
            m_detailToMaster.Remove(detailItemProperty);

            this.OnMappingChanged();

            if (recursive)
            {
                this.UnmapMasterItemProperties(masterItemProperty.ItemPropertiesInternal);
                this.UnmapDetailItemProperties(detailItemProperty.ItemPropertiesInternal);
            }
        }
 public SortDescriptionInfo(
     DataGridItemPropertyBase property,
     ListSortDirection direction)
 {
     m_property  = property;
     m_direction = direction;
 }
    protected DataGridItemPropertyBase( DataGridItemPropertyBase template )
      : this()
    {
      m_name = template.m_name;
      m_dataType = template.m_dataType;
      m_title = template.m_title;
      m_synonym = template.m_synonym;
      m_flags[ DataGridItemPropertyBaseFlags.IsReadOnly ] = template.m_flags[ DataGridItemPropertyBaseFlags.IsReadOnly ];
      m_flags[ DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertionSet ] = template.m_flags[ DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertionSet ];
      m_flags[ DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertion ] = template.m_flags[ DataGridItemPropertyBaseFlags.IsOverrideReadOnlyForInsertion ];
      m_flags[ DataGridItemPropertyBaseFlags.IsASubRelationshipSet ] = template.m_flags[ DataGridItemPropertyBaseFlags.IsASubRelationshipSet ];
      m_flags[ DataGridItemPropertyBaseFlags.IsASubRelationship ] = template.m_flags[ DataGridItemPropertyBaseFlags.IsASubRelationship ];
      m_flags[ DataGridItemPropertyBaseFlags.IsBrowsable ] = template.m_flags[ DataGridItemPropertyBaseFlags.IsBrowsable ];
      m_flags[ DataGridItemPropertyBaseFlags.CalculateDistinctValues ] = template.m_flags[ DataGridItemPropertyBaseFlags.CalculateDistinctValues ];
      m_converter = template.m_converter;
      m_converterCulture = template.m_converterCulture;
      m_converterParameter = template.m_converterParameter;
      this.FilterCriterion = template.m_filterCriterion;
      m_foreignKeyDescription = template.m_foreignKeyDescription;
      m_maxDistinctValues = template.m_maxDistinctValues;
      m_sortComparer = template.m_sortComparer;
      this.DistinctValuesEqualityComparer = template.DistinctValuesEqualityComparer;
      this.DistinctValuesSortComparer = template.DistinctValuesSortComparer;

      // FilterCriterionChanged is not cloned since only used after the clone occurs
      this.PropertyChanged += template.PropertyChanged;
      this.QueryDistinctValue += template.m_queryDistinctValue;
    }
        internal object[] GetItemPropertyDistinctValues(DataGridItemPropertyBase dataGridItemProperty)
        {
            if (m_queryableSource == null)
            {
                return(new object[0]);
            }

            IQueryable distinctQueryable = m_queryableSource.GetSubGroupsAndCountsQueryable(dataGridItemProperty.Name, false, ListSortDirection.Ascending);

            List <object> distinctValuesAndCounts = new List <object>();

            try
            {
                System.Collections.IEnumerator enumerator = distinctQueryable.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    QueryableExtensions.IQueryableGroupNameCountPair current = enumerator.Current as QueryableExtensions.IQueryableGroupNameCountPair;

                    if (current != null)
                    {
                        distinctValuesAndCounts.Add(current.GroupName);
                    }
                }

                return(distinctValuesAndCounts.ToArray());
            }
            catch
            {
                // TimeOut exception on the connection or other.
                return(new object[0]);
            }
        }
        private DataGridItemPropertyRoute(DataGridItemPropertyBase itemProperty, DataGridItemPropertyRoute parent)
        {
            Debug.Assert(itemProperty != null);

            m_itemProperty = itemProperty;
            m_parent       = parent;
        }
        internal override void OnEditBegun(DataGridItemEventArgs e)
        {
            object item = e.Item;

            DataGridPageManagerBase pageManager = this.RootGroup.GetVirtualPageManager();

            if (!pageManager.IsItemDirty(item))
            {
                // First time we enter edit on this item.
                DataGridItemPropertyCollection itemProperties = this.ItemProperties;
                int count = itemProperties.Count;

                string[] propertyNames = new string[count];
                object[] cachedValues  = new object[count];

                for (int i = 0; i < count; i++)
                {
                    DataGridItemPropertyBase itemProperty = itemProperties[i];
                    propertyNames[i] = itemProperty.Name;
                    cachedValues[i]  = itemProperty.GetValue(item);
                }

                // Cache the values of the never edited before row.  This will help the developer find the corresponding row
                // in the source when times comes to commit the changes to the data source.
                pageManager.SetCachedValuesForItem(item, propertyNames, cachedValues);
            }

            base.OnEditBegun(e);
        }
        private void MapItemProperties(DataGridItemPropertyBase masterItemProperty, DataGridItemPropertyBase detailItemProperty)
        {
            if ((masterItemProperty == null) || (detailItemProperty == null))
            {
                return;
            }

            DataGridItemPropertyBase mappedItemProperty;

            if (m_masterToDetail.TryGetValue(masterItemProperty, out mappedItemProperty))
            {
                if (mappedItemProperty == detailItemProperty)
                {
                    return;
                }

                this.UnmapMasterItemProperty(masterItemProperty);
            }

            this.UnmapDetailItemProperty(detailItemProperty);

            m_masterToDetail[masterItemProperty] = detailItemProperty;
            m_detailToMaster[detailItemProperty] = masterItemProperty;

            this.OnMappingChanged();
            this.MapItemProperties(masterItemProperty.ItemPropertiesInternal, detailItemProperty.ItemPropertiesInternal);
        }
        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;
        }
示例#14
0
        internal InitializeItemPropertyEventArgs(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                throw new ArgumentNullException("itemProperty");
            }

            m_itemProperty = itemProperty;
        }
        internal void PushDescendant(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                throw new ArgumentNullException("itemProperty");
            }

            this.PushDescendant(PropertyRouteBuilder.ToSegment(itemProperty));
        }
        private void MapDetailItemProperty(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                return;
            }

            var collection = itemProperty.ContainingCollection;

            if (collection == null)
            {
                return;
            }

            DataGridItemPropertyCollection mappedItemProperties;
            DataGridItemPropertyBase       mappedItemProperty;

            var owner = collection.Owner;

            if (owner == null)
            {
                Debug.Assert(collection == m_detailItemProperties);
                if (collection != m_detailItemProperties)
                {
                    return;
                }

                mappedItemProperties = m_masterItemProperties;
            }
            else
            {
                if (!m_detailToMaster.TryGetValue(owner, out mappedItemProperty))
                {
                    return;
                }

                mappedItemProperties = mappedItemProperty.ItemPropertiesInternal;
            }

            if (mappedItemProperties == null)
            {
                return;
            }

            mappedItemProperty = (!string.IsNullOrEmpty(itemProperty.Synonym)) ? mappedItemProperties[itemProperty.Synonym] : null;

            if (mappedItemProperty != null)
            {
                this.MapItemProperties(mappedItemProperty, itemProperty);
            }
            else
            {
                this.UnmapDetailItemProperty(itemProperty);
            }
        }
        private void MapMasterItemProperty(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                return;
            }

            var collection = itemProperty.ContainingCollection;

            if (collection == null)
            {
                return;
            }

            DataGridItemPropertyCollection mappedItemProperties;
            DataGridItemPropertyBase       mappedItemProperty;

            var owner = collection.Owner;

            if (owner == null)
            {
                Debug.Assert(collection == m_masterItemProperties);
                if (collection != m_masterItemProperties)
                {
                    return;
                }

                mappedItemProperties = m_detailItemProperties;
            }
            else
            {
                if (!m_masterToDetail.TryGetValue(owner, out mappedItemProperty))
                {
                    return;
                }

                mappedItemProperties = mappedItemProperty.ItemPropertiesInternal;
            }

            if (mappedItemProperties == null)
            {
                return;
            }

            mappedItemProperty = mappedItemProperties.GetForSynonym(itemProperty.Name);

            if (mappedItemProperty != null)
            {
                this.MapItemProperties(itemProperty, mappedItemProperty);
            }
            else
            {
                this.UnmapMasterItemProperty(itemProperty);
            }
        }
示例#18
0
            public override object GetValue(object component)
            {
                DataGridItemPropertyBase dataGridItemProperty = this.DataGridItemProperty;

                if (dataGridItemProperty == null)
                {
                    return(null);
                }

                return(dataGridItemProperty.GetValue(base.GetValue(component)));
            }
        internal override void RefreshDistinctValuesForField(DataGridItemPropertyBase dataGridItemProperty)
        {
            if (dataGridItemProperty == null)
            {
                return;
            }

            if (dataGridItemProperty.CalculateDistinctValues == false)
            {
                return;
            }

            // List containing current column distinct values
            HashSet <object> currentColumnDistinctValues = new HashSet <object>();

            ReadOnlyObservableHashList readOnlyColumnDistinctValues = null;

            // If the key is not set in DistinctValues yet, do not calculate distinct values for this field
            if (!(( DistinctValuesDictionary )this.DistinctValues).InternalTryGetValue(dataGridItemProperty.Name, out readOnlyColumnDistinctValues))
            {
                return;
            }

            ObservableHashList columnDistinctValues = readOnlyColumnDistinctValues.InnerObservableHashList;

            // We use the DistinctValuesSortComparer if present, else the SortComparer for the DataGridItemProperty, else,
            // the Comparer used is the one of the base class.
            IComparer distinctValuesSortComparer = dataGridItemProperty.DistinctValuesSortComparer;

            if (distinctValuesSortComparer == null)
            {
                distinctValuesSortComparer = dataGridItemProperty.SortComparer;
            }

            using (columnDistinctValues.DeferINotifyCollectionChanged())
            {
                DataGridVirtualizingQueryableCollectionViewGroupRoot rootGroup = this.RootGroup as DataGridVirtualizingQueryableCollectionViewGroupRoot;

                Debug.Assert(rootGroup != null);

                object[] distinctValues = rootGroup.GetItemPropertyDistinctValues(dataGridItemProperty);

                foreach (object distinctValue in distinctValues)
                {
                    // Compute current value to be able to remove unused values
                    currentColumnDistinctValues.Add(distinctValue);
                }

                DataGridCollectionViewBase.RemoveUnusedDistinctValues(
                    distinctValuesSortComparer, currentColumnDistinctValues, columnDistinctValues, null);
            }
        }
        private void UnregisterItemProperty(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                return;
            }

            if (!m_listeningToPropertyChanged.Remove(itemProperty))
            {
                return;
            }

            this.UnregisterItemProperties(itemProperty.ItemPropertiesInternal);
            PropertyChangedEventManager.RemoveListener(itemProperty, this, string.Empty);
        }
示例#21
0
            public override void SetValue(object component, object value)
            {
                if (component is EmptyDataItem)
                {
                    throw new InvalidOperationException("An attempt was made to set a value on an empty data item.");
                }

                DataGridItemPropertyBase dataGridItemProperty = this.DataGridItemProperty;

                if (dataGridItemProperty == null)
                {
                    return;
                }

                dataGridItemProperty.SetValue(component, value);
            }
        private void OnItemPropertyPropertyChanged(DataGridItemPropertyBase itemProperty, PropertyChangedEventArgs e)
        {
            var rootCollection = ItemsSourceHelper.GetRootCollection(itemProperty);

            if (rootCollection == null)
            {
                return;
            }

            using (this.DeferMappingChanged())
            {
                if (string.IsNullOrEmpty(e.PropertyName) || (e.PropertyName == DataGridItemPropertyBase.SynonymPropertyName))
                {
                    if (rootCollection == m_detailItemProperties)
                    {
                        this.MapDetailItemProperty(itemProperty);
                    }
                }

                if (string.IsNullOrEmpty(e.PropertyName) || (e.PropertyName == DataGridItemPropertyBase.ItemPropertiesInternalPropertyName))
                {
                    var itemProperties = itemProperty.ItemPropertiesInternal;
                    if (itemProperties != null)
                    {
                        this.UnregisterItemProperties(itemProperties);
                        this.RegisterItemProperties(itemProperties);

                        if (rootCollection == m_masterItemProperties)
                        {
                            foreach (var childItemProperty in itemProperties)
                            {
                                this.MapMasterItemProperty(childItemProperty);
                            }
                        }
                        else if (rootCollection == m_detailItemProperties)
                        {
                            foreach (var childItemProperty in itemProperties)
                            {
                                this.MapDetailItemProperty(childItemProperty);
                            }
                        }
                    }
                }
            }
        }
        private static PropertyRouteSegment ToSegment(DataGridItemPropertyBase itemProperty)
        {
            Debug.Assert(itemProperty != null);

            var route = PropertyRouteParser.Parse(itemProperty.Name);

            if (route == null)
            {
                throw new ArgumentException("Unexpected DataGridItemPropertyBase.Name property value.", "itemProperty");
            }

            if (route.Parent == null)
            {
                return(route.Current);
            }

            return(new PropertyRouteSegment(PropertyRouteSegmentType.Other, itemProperty.Name));
        }
        private void UnmapDetailItemProperty(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                return;
            }

            DataGridItemPropertyBase mappedItemProperty;

            if (!m_detailToMaster.TryGetValue(itemProperty, out mappedItemProperty))
            {
                return;
            }

            Debug.Assert(mappedItemProperty != null);

            this.UnmapItemProperties(mappedItemProperty, itemProperty, true);
        }
        internal static DataGridItemPropertyRoute Create(DataGridItemPropertyBase itemProperty)
        {
            if (itemProperty == null)
            {
                return(null);
            }

            var collection = itemProperty.ContainingCollection;

            if (collection == null)
            {
                return(new DataGridItemPropertyRoute(itemProperty));
            }

            return(new DataGridItemPropertyRoute(
                       itemProperty,
                       DataGridItemPropertyRoute.Create(collection.Owner)));
        }
    internal override void RefreshDistinctValuesForField( DataGridItemPropertyBase dataGridItemProperty )
    {
      if( dataGridItemProperty == null )
        return;

      if( dataGridItemProperty.CalculateDistinctValues == false )
        return;

      // List containing current column distinct values
      HashSet<object> currentColumnDistinctValues = new HashSet<object>();

      ReadOnlyObservableHashList readOnlyColumnDistinctValues = null;

      // If the key is not set in DistinctValues yet, do not calculate distinct values for this field
      if( !( ( DistinctValuesDictionary )this.DistinctValues ).InternalTryGetValue( dataGridItemProperty.Name, out readOnlyColumnDistinctValues ) )
        return;

      ObservableHashList columnDistinctValues = readOnlyColumnDistinctValues.InnerObservableHashList;

      // We use the DistinctValuesSortComparer if present, else the SortComparer for the DataGridItemProperty, else, 
      // the Comparer used is the one of the base class.
      IComparer distinctValuesSortComparer = dataGridItemProperty.DistinctValuesSortComparer;

      if( distinctValuesSortComparer == null )
        distinctValuesSortComparer = dataGridItemProperty.SortComparer;

      using( columnDistinctValues.DeferINotifyCollectionChanged() )
      {
        DataGridVirtualizingQueryableCollectionViewGroupRoot rootGroup = this.RootGroup as DataGridVirtualizingQueryableCollectionViewGroupRoot;

        Debug.Assert( rootGroup != null );

        object[] distinctValues = rootGroup.GetItemPropertyDistinctValues( dataGridItemProperty );

        foreach( object distinctValue in distinctValues )
        {
          // Compute current value to be able to remove unused values
          currentColumnDistinctValues.Add( distinctValue );
        }

        DataGridCollectionViewBase.RemoveUnusedDistinctValues( 
          distinctValuesSortComparer, currentColumnDistinctValues, columnDistinctValues, null );
      }
    }
    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;
    }
    protected DataGridItemPropertyBase( DataGridItemPropertyBase template )
    {
      m_name = template.m_name;
      m_dataType = template.m_dataType;
      m_title = template.m_title;
      m_readOnly = template.m_readOnly;
      m_overrideReadOnlyForInsertion = template.m_overrideReadOnlyForInsertion;
      m_isASubRelationship = template.m_isASubRelationship;
      m_browsable = template.m_browsable;
      m_calculateDistinctValues = template.m_calculateDistinctValues;
      m_converter = template.m_converter;
      m_converterCulture = template.m_converterCulture;
      m_converterParameter = template.m_converterParameter;
      this.FilterCriterion = template.m_filterCriterion;
      m_foreignKeyDescription = template.m_foreignKeyDescription;
      m_maxDistinctValues = template.m_maxDistinctValues;
      m_sortComparer = template.m_sortComparer;
      this.DistinctValuesEqualityComparer = template.DistinctValuesEqualityComparer;
      this.DistinctValuesSortComparer = template.DistinctValuesSortComparer;

      // FilterCriterionChanged is not cloned since only used after the clone occurs
      this.PropertyChanged += template.PropertyChanged;
      this.QueryDistinctValue += template.m_queryDistinctValue;
    }
        protected DataGridItemPropertyBase(DataGridItemPropertyBase template)
        {
            m_name     = template.m_name;
            m_dataType = template.m_dataType;
            m_title    = template.m_title;
            m_readOnly = template.m_readOnly;
            m_overrideReadOnlyForInsertion = template.m_overrideReadOnlyForInsertion;
            m_isASubRelationship           = template.m_isASubRelationship;
            m_browsable = template.m_browsable;
            m_calculateDistinctValues = template.m_calculateDistinctValues;
            m_converter                         = template.m_converter;
            m_converterCulture                  = template.m_converterCulture;
            m_converterParameter                = template.m_converterParameter;
            this.FilterCriterion                = template.m_filterCriterion;
            m_foreignKeyDescription             = template.m_foreignKeyDescription;
            m_maxDistinctValues                 = template.m_maxDistinctValues;
            m_sortComparer                      = template.m_sortComparer;
            this.DistinctValuesEqualityComparer = template.DistinctValuesEqualityComparer;
            this.DistinctValuesSortComparer     = template.DistinctValuesSortComparer;

            // FilterCriterionChanged is not cloned since only used after the clone occurs
            this.PropertyChanged    += template.PropertyChanged;
            this.QueryDistinctValue += template.m_queryDistinctValue;
        }
 private void AddFilteredItemProperty( DataGridItemPropertyBase itemProperty )
 {
   m_filteredItemProperties.Add( itemProperty );
 }
 internal abstract void RefreshDistinctValuesForField( DataGridItemPropertyBase dataGridItemProperty );
 public PropertyDescriptorFromItemPropertyBase( DataGridItemPropertyBase dataGridItemProperty )
   : base( dataGridItemProperty.Name )
 {
   m_dataGridItemProperty = new WeakReference( dataGridItemProperty );
   m_propertyType = dataGridItemProperty.DataType;
 }
 internal QueryAutoFilterDistinctValuesEventArgs(DataGridItemPropertyBase itemProperty)
 {
     m_itemProperty   = itemProperty;
     m_distinctValues = new List <object>();
 }
 internal QueryAutoFilterDistinctValuesEventArgs( DataGridItemPropertyBase itemProperty )
 {
   m_itemProperty = itemProperty;
   m_distinctValues = new List<object>();
 }
 private DataGridItemPropertyRoute(DataGridItemPropertyBase itemProperty)
     : this(itemProperty, null)
 {
 }
 internal bool TryGetDetailItemProperty(DataGridItemPropertyBase masterItemProperty, out DataGridItemPropertyBase detailItemProperty)
 {
     return(DataGridItemPropertyMap.TryGetTargetItemProperty(m_masterToDetail, masterItemProperty, out detailItemProperty));
 }
        public int Compare(RawItem xRawItem, RawItem yRawItem)
        {
            if (xRawItem == null)
            {
                if (yRawItem == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (yRawItem == null)
                {
                    return(1);
                }
            }

            ListSortDirection         lastSortDirection = ListSortDirection.Ascending;
            SortDescriptionCollection sortDescriptions  = m_collectionView.SortDescriptions;
            int sortDescriptionCount = sortDescriptions.Count;

            if (sortDescriptionCount > 0)
            {
                int result;
                DataGridItemPropertyCollection itemProperties = m_collectionView.ItemProperties;

                for (int i = 0; i < sortDescriptionCount; i++)
                {
                    SortDescription sortDescription = sortDescriptions[i];
                    lastSortDirection = sortDescription.Direction;
                    DataGridItemPropertyBase dataProperty = itemProperties[sortDescription.PropertyName];

                    if (dataProperty == null)
                    {
                        continue;
                    }

                    ISupportInitialize supportInitialize = dataProperty as ISupportInitialize;
                    object             xData             = null;
                    object             yData             = null;

                    if (supportInitialize != null)
                    {
                        supportInitialize.BeginInit();
                    }

                    try
                    {
                        xData = dataProperty.GetValue(xRawItem.DataItem);
                        yData = dataProperty.GetValue(yRawItem.DataItem);
                    }
                    finally
                    {
                        if (supportInitialize != null)
                        {
                            supportInitialize.EndInit();
                        }
                    }

                    IComparer sortComparer = dataProperty.SortComparer;

                    if (sortComparer != null)
                    {
                        result = sortComparer.Compare(xData, yData);
                    }
                    else
                    {
                        result = ObjectDataStore.CompareData(xData, yData);
                    }

                    if (result != 0)
                    {
                        if (lastSortDirection == ListSortDirection.Descending)
                        {
                            result = -result;
                        }

                        return(result);
                    }
                }
            }

            if (lastSortDirection == ListSortDirection.Descending)
            {
                return(yRawItem.Index - xRawItem.Index);
            }

            return(xRawItem.Index - yRawItem.Index);
        }
        private static bool TryGetTargetItemProperty(Dictionary <DataGridItemPropertyBase, DataGridItemPropertyBase> collection, DataGridItemPropertyBase sourceItemProperty, out DataGridItemPropertyBase targetItemProperty)
        {
            if ((collection != null) && (sourceItemProperty != null) && collection.TryGetValue(sourceItemProperty, out targetItemProperty))
            {
                return(true);
            }

            targetItemProperty = default(DataGridItemPropertyBase);

            return(false);
        }
    private void AddValidItemProperty( DataGridItemPropertyBase itemProperty )
    {
      if( !itemProperty.Browsable )
        return;

      if( itemProperty.IsASubRelationship )
        return;

      if( m_itemProperties[ itemProperty.Name ] != null )
        return;

      m_itemProperties.Add( itemProperty );
    }
示例#40
0
 public PropertyDescriptorFromItemPropertyBase(DataGridItemPropertyBase dataGridItemProperty)
     : base(dataGridItemProperty.Name)
 {
     m_dataGridItemProperty = new WeakReference(dataGridItemProperty);
     m_propertyType         = dataGridItemProperty.DataType;
 }
示例#41
0
    public static FieldDescriptor CreateFieldFromDataGridItemProperty( DataGridItemPropertyBase itemProperty )
    {
      DataGridItemPropertyBase.PropertyDescriptorFromItemPropertyBase propertyDescriptor =
        itemProperty.GetPropertyDescriptorForBinding();

      string name = propertyDescriptor.Name;
      Type type = propertyDescriptor.PropertyType;

      // If an ItemProperty is in the public ItemProperties of the collection view,
      // we always want to consider that property is not a detail and browsable.
      return new FieldDescriptor( name,
                                  propertyDescriptor.DisplayName,
                                  propertyDescriptor.PropertyType,
                                  propertyDescriptor,
                                  null,
                                  null,
                                  itemProperty.IsReadOnly,
                                  itemProperty.OverrideReadOnlyForInsertion.GetValueOrDefault( false ),
                                  false,
                                  true,
                                  false,
                                  itemProperty is DataGridUnboundItemProperty,
                                  itemProperty.ForeignKeyDescription );
    }
    internal object[] GetItemPropertyDistinctValues( DataGridItemPropertyBase dataGridItemProperty )
    {
      if( m_queryableSource == null )
        return new object[ 0 ];

      IQueryable distinctQueryable = m_queryableSource.GetSubGroupsAndCountsQueryable( dataGridItemProperty.Name, false, ListSortDirection.Ascending );

      List<object> distinctValuesAndCounts = new List<object>();
      try
      {
        System.Collections.IEnumerator enumerator = distinctQueryable.GetEnumerator();

        while( enumerator.MoveNext() )
        {
          QueryableExtensions.IQueryableGroupNameCountPair current = enumerator.Current as QueryableExtensions.IQueryableGroupNameCountPair;

          if( current != null )
            distinctValuesAndCounts.Add( current.GroupName );
        }

        return distinctValuesAndCounts.ToArray();
      }
      catch
      {
        // TimeOut exception on the connection or other.
        return new object[ 0 ];
      }
    }