コード例 #1
0
 public ValueValidationEventArgs(PropertyEnumerator propEnum, PropertyEnumerator invalidPropEnum, object value, PropertyValue.ValueValidationResult result)
     : base(propEnum)
 {
     _valueValidationResult = result;
     _valueToValidate = value;
     _invalidPropEnum = invalidPropEnum;
 }
コード例 #2
0
        public PropertyValueIndirect(PropertyGrid grid, PropertyValue parentValue, object target, PropertyDescriptor propertyDescriptor, Attribute[] attributes)
            : base(parentValue)
        {
            Grid = grid;

            _targets.Add(new Utilities.KeyValuePair(propertyDescriptor, target));

            Attributes = attributes;

//            ExtractDisplayedValues();
        }
コード例 #3
0
        public void InitializeContent(PropertyEnumerator propEnum, string currentValue, object valueKey)
        {
            _ownerPropertyEnumerator = propEnum;

            int width = 0;

            _propValue = (valueKey == null ? propEnum.Property.Value : propEnum.Property.GetValue(valueKey));

            Graphics graphics = CreateGraphics();

            object[] displayedValues = _propValue.GetDisplayedValues();
            foreach(object str in displayedValues)
            {
                Items.Add(str.ToString());

                Size size = Win32Calls.GetTextExtent(graphics, str.ToString(), propEnum.Property.ParentGrid.Font);
                if (width < size.Width)
                    width = size.Width;
            }

            Win32Calls.TEXTMETRIC tm = new Win32Calls.TEXTMETRIC();
            Win32Calls.GetTextMetrics(graphics, propEnum.Property.ParentGrid.Font, ref tm);

            graphics.Dispose();

            ItemHeight = tm.tmHeight + propEnum.Property.ParentGrid.PropertyVerticalMargin - 2;

            Height = Math.Max(ItemHeight, Math.Min(200, ItemHeight * displayedValues.Length));

            int margin = propEnum.Property.ParentGrid.GlobalTextMargin;
            Width = width + 2 * margin;
            if (_propValue.ImageList != null)
                Width += ItemHeight + margin;

            DrawMode = DrawMode.OwnerDrawFixed;

            SelectedItem = currentValue;
//            SelectedItem = _propValue.DisplayString;
        }
コード例 #4
0
ファイル: PropertyValue.cs プロジェクト: ChrisMoreton/Test3
        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;
        }
コード例 #5
0
ファイル: PropertyValue.cs プロジェクト: ChrisMoreton/Test3
 public PropertyValue(PropertyValue parentValue) : this()
 {
     _parentValue = parentValue;
 }
コード例 #6
0
ファイル: PropertyValue.cs プロジェクト: ChrisMoreton/Test3
 protected internal virtual void OnChildValueChanged(PropertyValue childPropValue)
 {
 }
コード例 #7
0
ファイル: PropertyValue.cs プロジェクト: ChrisMoreton/Test3
 protected virtual void OnParentValueChanged(PropertyValue parentPropValue)
 {
 }
コード例 #8
0
        protected internal override void OnChildValueChanged(PropertyValue childPropValue)
        {
            if ((childPropValue == null) || !childPropValue.ChildValueCreatedBySPG)
            {
                string str = "";

                PropertyEnumerator childEnum = mOwnerEnumerator.Children;
                char separator = mOwnerEnumerator.Property.Value.GroupedValueSeparator;
                while (childEnum != childEnum.RightBound)
                {
                    str += childEnum.Property.Value.GetStringValue();
                    childEnum.MoveNext();

                    if (childEnum != childEnum.RightBound)
                    {
                        str += separator;
                        str += " ";
                    }
                }

                SetValue(str, ValueUpdateSource.FromChild);
            }
        }
コード例 #9
0
        public PropertyValueIndirect(PropertyGrid grid, PropertyValue parentValue, PropertyDescriptor propertyDescriptor)
            : base(parentValue)
        {
            Grid = grid;

            _targets.Add(new Utilities.KeyValuePair(propertyDescriptor, null));

//            ExtractDisplayedValues();
        }
コード例 #10
0
 public PropertyValueSimulated(PropertyGrid grid, PropertyValue parentValue, PropertyDescriptor propertyDescriptor)
     :
     base(grid, parentValue, propertyDescriptor)
 {
 }
コード例 #11
0
 public PropertyValueSimulated(PropertyGrid grid, PropertyValue parentValue, object target, PropertyDescriptor propertyDescriptor)
     : base(grid, parentValue, target, propertyDescriptor, null)
 {
 }
コード例 #12
0
 public ValueValidationEventArgs(PropertyEnumerator propEnum, PropertyEnumerator invalidPropEnum, object value, PropertyValue.ValueValidationResult result, Exception e)
     : this(propEnum, invalidPropEnum, value, result)
 {
     _exception = e;
 }