Example #1
0
        internal void SetManuallyDisabled(PropertyEnumerator propEnum, object containerInstance, string memberName)
        {
            if (containerInstance != null)
            {
                _canBeDisabledManually = true;
                _enabledVariable       = new PropertyValueIndirect(_grid, null, containerInstance, TypeDescriptor.GetProperties(containerInstance)[memberName], null);
                _enabledVariable.Grid  = ParentGrid;
                ParentGrid.EnableProperty(propEnum, (GetManuallyDisabledVariable() && !ParentGrid.Grid.IsAncestorDisabled(propEnum)));
//                _enabled = (GetManuallyDisabledVariable() && !ParentGrid.Grid.IsAncestorDisabled(propEnum));

//                if (_grid != null)
//                  _grid.Grid.Invalidate();
            }
        }
Example #2
0
        public void AddValue(object key, object container, PropertyDescriptor propertyDescriptor, params Attribute[] attributes)
        {
            PropertyValue propertyValue;

            if ((propertyValue = (PropertyValue)_additionalValues[key]) == null)
            {
                propertyValue = new PropertyValueIndirect(_grid, null, container, propertyDescriptor, attributes);

                _additionalValues.Add(key, propertyValue);

                propertyValue.OwnerEnumerator    = Value.OwnerEnumerator;
                propertyValue.AdditionalValueKey = key;
            }
            else
            {
                (propertyValue as PropertyValueIndirect).AddTargetInstance(container, propertyDescriptor);
            }
        }
Example #3
0
        internal void SetManuallyDisabled(PropertyEnumerator propEnum, object containerInstance, string memberName)
		{
			if (containerInstance != null)
			{
				_canBeDisabledManually = true;
                _enabledVariable = new PropertyValueIndirect(_grid, null, containerInstance, TypeDescriptor.GetProperties(containerInstance)[memberName], null);
                _enabledVariable.Grid = ParentGrid;
                ParentGrid.EnableProperty(propEnum, (GetManuallyDisabledVariable() && !ParentGrid.Grid.IsAncestorDisabled(propEnum)));
//                _enabled = (GetManuallyDisabledVariable() && !ParentGrid.Grid.IsAncestorDisabled(propEnum));

//                if (_grid != null)
  //                  _grid.Grid.Invalidate();
            }
		}
Example #4
0
        public void AddValue(object key, object container, PropertyDescriptor propertyDescriptor, params Attribute[] attributes)
        {
            PropertyValue propertyValue;
            if ((propertyValue = (PropertyValue)_additionalValues[key]) == null)
            {
                propertyValue = new PropertyValueIndirect(_grid, null, container, propertyDescriptor, attributes);

                _additionalValues.Add(key, propertyValue);

                propertyValue.OwnerEnumerator = Value.OwnerEnumerator;
                propertyValue.AdditionalValueKey = key;
            }
            else
            {
                (propertyValue as PropertyValueIndirect).AddTargetInstance(container, propertyDescriptor);
            }
        }
Example #5
0
        protected internal PropertyValue[] GetChildValues(object[] targetInstances, PropertyDescriptor[] propertyDescriptors)
        {
            PropertyValue[] valueArray;

            Hashtable propertyDescriptorDefs = new Hashtable(); // <PropertyDescriptor, List<PropertyDescriptor>>

            PropertyDescriptorCollection collection = null;
            bool firstTarget = true;
            bool toBeSorted = true;
            for(int i=0; i<targetInstances.Length; i++)
            {
                object targetInstance = targetInstances[i];

                PropertyDescriptorCollection pdCollection = OwnerEnumerator.Property.ParentGrid.
                    GetPropertyDescriptors(targetInstance, propertyDescriptors[i], out toBeSorted);
                if (collection == null)
                {
                    PropertyDescriptor[] array = new PropertyDescriptor[pdCollection.Count];
                    pdCollection.CopyTo(array, 0);
                    collection = new PropertyDescriptorCollection(array);
                }

                foreach (PropertyDescriptor propertyDescriptor in pdCollection)
                {
                    MergablePropertyAttribute mergeAttr = propertyDescriptor.Attributes[typeof(MergablePropertyAttribute)]
                        as MergablePropertyAttribute;
                    if ((mergeAttr != null) && (mergeAttr.AllowMerge == false))
                        continue;

                    if (firstTarget)
                    {
                        // For the first target instance, we store all the PropertyDescriptors
                        ArrayList pdList = new ArrayList();
                        pdList.Add(propertyDescriptor);

                        propertyDescriptorDefs.Add(propertyDescriptor, pdList);
                    }
                    else
                    {
                        // For all the remaining target instances, we compare the PropertyDescriptors
                        // to the first set of stored PropertyDescriptors. Their name and property type must
                        // correspond
                        ArrayList existPdList = (ArrayList)propertyDescriptorDefs[propertyDescriptor];
                        if (existPdList != null)
                        {
                            // If the propertyDesriptors match, we increment a count
                            if (OwnerEnumerator.Property.ParentGrid.MatchPropertyDescriptors(
                                (PropertyDescriptor)existPdList[0], propertyDescriptor))
                            {
                                existPdList.Add(propertyDescriptor);
                            }
                            // else the PropertyDescriptor is not eligible and is removed
                            else
                                propertyDescriptorDefs.Remove(propertyDescriptor);
                        }
                    }
                }

                firstTarget = false;
            }

            ArrayList validPropertyDescriptors = new ArrayList();

            // Ensure that we count only propertyDescriptors that are present in all target instances
            foreach (ArrayList pdList in propertyDescriptorDefs.Values)
            {
                if (pdList.Count != targetInstances.Length)
                    collection.Remove((PropertyDescriptor)pdList[0]);
            }

            // Sort the collection
            if (toBeSorted && (Grid.PropertyComparer != null))
                collection = collection.Sort(Grid.PropertyComparer);

            PropertyTypeDescriptorContext context = new PropertyTypeDescriptorContext(null, targetInstances[0], null,
                OwnerEnumerator.Property.ParentGrid);
            bool readOnlyProperties = TypeConverter.GetCreateInstanceSupported(context);
            valueArray = new PropertyValue[collection.Count];
            int index = 0;
            foreach (PropertyDescriptor descriptor in collection)
            {
                PropertyValue propValue;
                try
                {
                    object obj = UnderlyingValue;
                    if (obj is ICustomTypeDescriptor)
                        obj = ((ICustomTypeDescriptor)obj).GetPropertyOwner(descriptor);

                    // TODO : pourquoi cette ligne ?
                    descriptor.GetValue(obj);
                }
                catch (Exception)
                {
                    // Reason : activeXHide ?
                }

                if (readOnlyProperties)
                    propValue = new PropertyValueSimulated(Grid, this, descriptor);
                else
                    propValue = new PropertyValueIndirect(Grid, this, UnderlyingValue, descriptor, null);

                propValue.ChildValueCreatedBySPG = true;

                PropertyIdAttribute attr = descriptor.Attributes[typeof(PropertyIdAttribute)] as PropertyIdAttribute;
                propValue.Id = (attr != null ? attr.Id : 0);

                valueArray[index++] = propValue;
            }

            return valueArray;
        }