Beispiel #1
0
        public void SetValueAtDesignTime(RadProperty property, object value)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(property, true);

            entry.IsSetAtDesignTime = true;
            int num = (int)this.SetValueCore(entry, (object)null, value, ValueSource.Local);
        }
Beispiel #2
0
        protected internal virtual object GetInheritedValue(RadProperty property)
        {
            if (this.GetBitState(1L) || this.GetBitState(2L))
            {
                return(RadProperty.UnsetValue);
            }
            int globalIndex = property.GlobalIndex;

            System.Type ownerType = property.OwnerType;
            object      obj       = RadProperty.UnsetValue;

            for (RadObject inheritanceParent = this.InheritanceParent; inheritanceParent != null; inheritanceParent = inheritanceParent.InheritanceParent)
            {
                if (ownerType.IsInstanceOfType((object)inheritanceParent))
                {
                    RadPropertyValue entry = inheritanceParent.propertyValues.GetEntry(property, false);
                    if (entry != null)
                    {
                        obj = entry.GetCurrentValue(true);
                        break;
                    }
                }
            }
            return(obj);
        }
Beispiel #3
0
        /// <summary>
        /// Gets notified that the specified object has bound to a property of ours.
        /// </summary>
        /// <param name="boundObject">The instance that has bound the specified property.</param>
        /// <param name="binding"></param>
        internal void OnPropertyBoundExternally(PropertyBinding binding, RadObject boundObject)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, true);

            //register the bound object and its property
            propVal.AddBoundObject(new PropertyBoundObject(boundObject, binding.BoundProperty));
        }
Beispiel #4
0
        /// <summary>
        /// Searches up in the chain of InheritanceParents for a value for the specified property.
        /// </summary>
        /// <param name="property">The property to examine.</param>
        /// <returns></returns>
        protected internal virtual object GetInheritedValue(RadProperty property)
        {
            if (this.GetBitState(DisposingStateKey) || this.GetBitState(DisposedStateKey))
            {
                return(RadProperty.UnsetValue);
            }

            int  propertyIndex     = property.GlobalIndex;
            Type propDeclaringType = property.OwnerType;

            object    value  = RadProperty.UnsetValue;
            RadObject parent = this.InheritanceParent;

            while (parent != null)
            {
                if (propDeclaringType.IsInstanceOfType(parent))
                {
                    RadPropertyValue propVal = parent.propertyValues.GetEntry(property, false);
                    if (propVal != null)
                    {
                        value = propVal.GetCurrentValue(true);
                        break;
                    }
                }

                parent = parent.InheritanceParent;
            }

            return(value);
        }
Beispiel #5
0
        /// <summary>
        /// Gets notified that the specified object has unbound itself from a property of ours.
        /// </summary>
        /// <param name="boundObject"></param>
        /// <param name="binding"></param>
        internal void OnPropertyUnboundExternally(PropertyBinding binding, RadObject boundObject)
        {
            if (this.IsDisposing)
            {
                return;
            }

            RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, false);

            if (propVal == null)
            {
                return;
            }

            propVal.BeginUpdate(true, false);

            //remove previously registered relations
            propVal.RemoveBoundObject(boundObject);

            if ((binding.BindingOptions & PropertyBindingOptions.TwoWay) == PropertyBindingOptions.TwoWay)
            {
                //reset the local value applied from the two-way binding
                this.ResetValueCore(propVal, ValueResetFlags.TwoWayBindingLocal);
            }

            if ((binding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue)
            {
                propVal.SetLocalValue(binding.GetValue());
            }

            propVal.EndUpdate(true, false);
            this.UpdateValueCore(propVal);
        }
Beispiel #6
0
        public ValueUpdateResult BindProperty(
            RadProperty propertyToBind,
            RadObject sourceObject,
            RadProperty sourceProperty,
            PropertyBindingOptions options)
        {
            if (sourceObject == null)
            {
                throw new ArgumentNullException("Binding source object");
            }
            if (sourceObject.IsDisposing || sourceObject.IsDisposed)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            RadPropertyValue entry = this.propertyValues.GetEntry(propertyToBind, true);

            if (entry.PropertyBinding != null)
            {
                entry.BeginUpdate(true, false);
                int num = (int)this.ResetValueCore(entry, ValueResetFlags.Binding);
                entry.EndUpdate(true, false);
            }
            PropertyBinding   binding           = new PropertyBinding(sourceObject, propertyToBind, sourceProperty, options);
            ValueUpdateResult valueUpdateResult = this.SetValueCore(entry, (object)binding, (object)null, ValueSource.PropertyBinding);

            if ((options & PropertyBindingOptions.NoChangeNotify) == (PropertyBindingOptions)0)
            {
                sourceObject.OnPropertyBoundExternally(binding, this);
            }
            return(valueUpdateResult);
        }
Beispiel #7
0
        internal ValueUpdateResult OnAnimationFinished(AnimatedPropertySetting setting)
        {
            //check whether we have registered animation setting for this element
            RadPropertyValue propVal = this.propertyValues.GetEntry(setting.Property, false);

            if (propVal == null)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            //check whether this is StyleSetting or regular Animation
            object      propModifier;
            ValueSource source;

            if (setting.IsStyleSetting)
            {
                propModifier = setting;
                source       = ValueSource.Style;
            }
            else
            {
                propModifier = null;
                source       = ValueSource.Animation;
            }

            return(this.SetValueCore(propVal, propModifier, null, source));
        }
Beispiel #8
0
        internal void OnPropertyUnboundExternally(PropertyBinding binding, RadObject boundObject)
        {
            if (this.IsDisposing)
            {
                return;
            }
            RadPropertyValue entry = this.propertyValues.GetEntry(binding.SourceProperty, false);

            if (entry == null)
            {
                return;
            }
            entry.BeginUpdate(true, false);
            entry.RemoveBoundObject(boundObject);
            if ((binding.BindingOptions & PropertyBindingOptions.TwoWay) == PropertyBindingOptions.TwoWay)
            {
                int num1 = (int)this.ResetValueCore(entry, ValueResetFlags.TwoWayBindingLocal);
            }
            if ((binding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue)
            {
                entry.SetLocalValue(binding.GetValue());
            }
            entry.EndUpdate(true, false);
            int num2 = (int)this.UpdateValueCore(entry);
        }
Beispiel #9
0
        /// <summary>
        /// Checks needed conditions to perform property update.
        /// </summary>
        /// <param name="propVal"></param>
        /// <param name="value"></param>
        internal void EnsurePropertySet(RadPropertyValue propVal, object value)
        {
            //1. It should not be marked as "Read-only"
            if (propVal.Metadata.ReadOnly)
            {
                throw new ArgumentException("Attemt to modify the value of a read-only property");
            }

            //2. Type of the specified value should match property type
            if (value != null && value != RadProperty.UnsetValue)
            {
                if (!RadProperty.IsValidType(value, propVal.Property.PropertyType))
                {
                    throw new ArgumentException("New value does not match declared property type.");
                }
            }

            //3. Is value valid - use metadata's defined callback
            if (propVal.Property.ValidateValueCallback != null)
            {
                if (!propVal.Property.ValidateValueCallback(value, this))
                {
                    throw new ArgumentException("Specified value " + value.ToString() + " is not valid for property " + propVal.Property.Name);
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Applies the specified value as Local for the desired property
        /// and raises the flag IsLocalValueSetAtDesignTime for that property.
        /// All design-time direct property modifications (e.g. item.Text = "Item1")
        /// should be done through this method for the property to be properly serialized.
        /// If a property is modified through a property grid, the custom property descriptor will automatically apply this logic.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="value"></param>
        internal void SetValueAtDesignTime(RadProperty property, object value)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(property, true);

            propVal.IsSetAtDesignTime = true;
            this.SetValueCore(propVal, null, value, ValueSource.Local);
        }
        public RadPropertyValue GetEntry(RadProperty prop, bool createNew)
        {
            if (prop == null)
            {
                throw new ArgumentNullException("RadProperty");
            }

            //check for property mapping
            if (this.propertyMapper != null)
            {
                RadProperty mappedProperty = this.propertyMapper(prop);
                if (mappedProperty != null)
                {
                    prop = mappedProperty;
                }
            }

            RadPropertyValue entry;

            if (!this.entries.TryGetValue(prop.GlobalIndex, out entry) && createNew)
            {
                entry = new RadPropertyValue(this.owner, prop);
                this.entries[prop.GlobalIndex] = entry;
            }

            return(entry);
        }
Beispiel #12
0
        protected internal virtual ValueUpdateResult ResetValueCore(
            RadPropertyValue propVal,
            ValueResetFlags flags)
        {
            if (flags == ValueResetFlags.None)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            object           currentValue = propVal.GetCurrentValue(false);
            ValueSource      valueSource  = propVal.ValueSource;
            RadPropertyValue source       = (RadPropertyValue)null;

            if (!propVal.IsCompositionLocked)
            {
                source = new RadPropertyValue(propVal);
            }
            propVal.BeginUpdate(true, false);
            if ((flags & ValueResetFlags.Animation) == ValueResetFlags.Animation)
            {
                int num1 = (int)this.SetValueCore(propVal, (object)null, (object)null, ValueSource.Animation);
            }
            if ((flags & ValueResetFlags.Local) == ValueResetFlags.Local)
            {
                int num2 = (int)this.SetValueCore(propVal, (object)null, RadProperty.UnsetValue, ValueSource.Local);
            }
            if ((flags & ValueResetFlags.DefaultValueOverride) == ValueResetFlags.DefaultValueOverride)
            {
                int num3 = (int)this.SetValueCore(propVal, (object)null, RadProperty.UnsetValue, ValueSource.DefaultValue);
            }
            if ((flags & ValueResetFlags.Binding) == ValueResetFlags.Binding)
            {
                int num4 = (int)this.SetValueCore(propVal, (object)null, (object)null, ValueSource.PropertyBinding);
            }
            if ((flags & ValueResetFlags.TwoWayBindingLocal) == ValueResetFlags.TwoWayBindingLocal)
            {
                int num5 = (int)this.SetValueCore(propVal, (object)null, RadProperty.UnsetValue, ValueSource.LocalFromBinding);
            }
            if ((flags & ValueResetFlags.Style) == ValueResetFlags.Style)
            {
                int num6 = (int)this.SetValueCore(propVal, (object)null, (object)null, ValueSource.Style);
            }
            if ((flags & ValueResetFlags.Inherited) == ValueResetFlags.Inherited)
            {
                int num7 = (int)this.SetValueCore(propVal, (object)null, RadProperty.UnsetValue, ValueSource.Inherited);
            }
            propVal.EndUpdate(true, false);
            if (propVal.IsCompositionLocked)
            {
                return(ValueUpdateResult.Updating);
            }
            ValueUpdateResult valueUpdateResult = this.RaisePropertyNotifications(propVal, currentValue, propVal.GetCurrentValue(true), valueSource);

            if (valueUpdateResult == ValueUpdateResult.Canceled)
            {
                propVal.Copy(source);
            }
            source?.Dispose();
            return(valueUpdateResult);
        }
Beispiel #13
0
 protected override object CoerceValue(RadPropertyValue propVal, object baseValue)
 {
     if (propVal.Property == RootRadElement.ControlBoundsProperty)
     {
         return((object)this.ElementTree.Control.Bounds);
     }
     return(base.CoerceValue(propVal, baseValue));
 }
Beispiel #14
0
 protected virtual object CoerceValue(RadPropertyValue propVal, object baseValue)
 {
     if (propVal.Metadata != null && propVal.Metadata.CoerceValueCallback != null)
     {
         return(propVal.Metadata.CoerceValueCallback(this, baseValue));
     }
     return(RadProperty.UnsetValue);
 }
Beispiel #15
0
        /// <summary>
        /// Notifies a binding source that a change occured in a two-way bound property.
        /// </summary>
        /// <param name="binding"></param>
        /// <param name="newValue"></param>
        internal void OnTwoWayBoundPropertyChanged(PropertyBinding binding, object newValue)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, false);

            if (propVal != null)
            {
                this.SetValueCore(propVal, null, newValue, ValueSource.LocalFromBinding);
            }
        }
Beispiel #16
0
        internal void RemoveAnimation(RadPropertyValue propVal)
        {
            AnimatedPropertySetting animation = this.GetCurrentAnimation(propVal);

            if (animation != null)
            {
                animation.RemovePreviousAnimation((RadElement)this, animation);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Marks the current PropertyValue entry for the specified property as "Set at design-time".
        /// This is used by our custom code-dom serializer to determine which properties needs to be persisted.
        /// </summary>
        /// <param name="property"></param>
        internal void SetPropertyValueSetAtDesignTime(RadProperty property)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(property, false);

            if (propVal != null)
            {
                propVal.IsSetAtDesignTime = true;
            }
        }
Beispiel #18
0
        protected internal virtual ValueUpdateResult UpdateValueCore(
            RadPropertyValue propVal)
        {
            object      currentValue = propVal.GetCurrentValue(false);
            ValueSource valueSource  = propVal.ValueSource;

            propVal.ComposeCurrentValue();
            return(this.RaisePropertyNotifications(propVal, currentValue, propVal.GetCurrentValue(false), valueSource));
        }
Beispiel #19
0
        /// <summary>
        /// Called when element style condition changes
        /// </summary>
        /// <param name="property"></param>
        internal void RemoveStylePropertySetting(RadProperty property)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(property, false);

            if (propVal != null)
            {
                this.ResetValueCore(propVal, ValueResetFlags.Style);
            }
        }
Beispiel #20
0
 internal AnimatedPropertySetting GetCurrentAnimation(
     RadPropertyValue propVal)
 {
     if (propVal.AnimationSetting != null)
     {
         return(propVal.AnimationSetting);
     }
     return(propVal.StyleSetting as AnimatedPropertySetting);
 }
Beispiel #21
0
        /// <summary>
        /// Performs the following logic:
        /// 1. Compares oldValue and newValue and returns ValueUpdateResult.NotChanged if they are equal.
        /// 2. Raises the PropertyChanging notification. If the event is canceled returns ValueUpdateResult.Canceled.
        /// 3. Raises PropertyChanged notification and returns ValueUpdateResult.Updated.
        /// </summary>
        /// <param name="propVal"></param>
        /// <param name="oldValue"></param>
        /// <param name="newValue"></param>
        /// <param name="oldSource"></param>
        /// <returns>The result of the operation.</returns>
        internal ValueUpdateResult RaisePropertyNotifications(RadPropertyValue propVal, object oldValue, object newValue, ValueSource oldSource)
        {
            if (!this.CanRaisePropertyChangeNotifications(propVal))
            {
                return(ValueUpdateResult.NotUpdated);
            }

            //in some cases we may run into composite property update and property notifications will not be needed.
            if (propVal.IsCompositionLocked)
            {
                return(ValueUpdateResult.Updating);
            }

            //compare the new value of the property with its previous one
            if (object.Equals(oldValue, newValue))
            {
                //current property value has not changed, do not raise notifications
                return(ValueUpdateResult.UpdatedNotChanged);
            }

            RadPropertyChangingEventArgs changingArgs = new RadPropertyChangingEventArgs(propVal.Property, oldValue, newValue, propVal.Metadata);

            this.OnPropertyChanging(changingArgs);

            ValueUpdateResult result;

            if (changingArgs.Cancel)
            {
                result = ValueUpdateResult.Canceled;
            }
            else
            {
#if DEBUG
                //Validate needed conditions to update the property
                //TODO: This is currently performed during debug cycle, may be it should be done in release also
                EnsurePropertySet(propVal, newValue);
#endif
                //change is accepted, fire changed notification
                RadPropertyChangedEventArgs changedArgs = new RadPropertyChangedEventArgs(propVal.Property, propVal.Metadata, oldValue, newValue, false, false, oldSource, propVal.ValueSource);
                this.OnPropertyChanged(changedArgs);

                //notify all objects bound to the property we have just updated
                propVal.NotifyBoundObjects();

                //use the metadata callback if specified
                if (propVal.Metadata.PropertyChangedCallback != null)
                {
                    propVal.Metadata.PropertyChangedCallback(this, changedArgs);
                }

                //value was successfully updated
                result = ValueUpdateResult.UpdatedChanged;
            }

            return(result);
        }
Beispiel #22
0
        public ValueUpdateResult UpdateValue(RadProperty property)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(property, false);

            if (entry == null)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            return(this.UpdateValueCore(entry));
        }
Beispiel #23
0
        public void RemoveStylePropertySetting(RadProperty property)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(property, false);

            if (entry == null)
            {
                return;
            }
            int num = (int)this.ResetValueCore(entry, ValueResetFlags.Style);
        }
Beispiel #24
0
        internal void OnBoundSourcePropertyChanged(RadProperty boundProperty)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(boundProperty, false);

            if (entry == null || entry.IsCompositionLocked)
            {
                return;
            }
            int num = (int)this.UpdateValueCore(entry);
        }
Beispiel #25
0
        internal void OnTwoWayBoundPropertyChanged(PropertyBinding binding, object newValue)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(binding.SourceProperty, false);

            if (entry == null)
            {
                return;
            }
            int num = (int)this.SetValueCore(entry, (object)null, newValue, ValueSource.LocalFromBinding);
        }
Beispiel #26
0
        public ValueUpdateResult UnbindProperty(RadProperty boundProperty)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(boundProperty, false);

            if (entry == null || entry.PropertyBinding == null)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            return(this.ResetValueCore(entry, ValueResetFlags.Binding));
        }
Beispiel #27
0
        /// <summary>
        /// Gets notified for a change in an animated property.
        /// </summary>
        /// <param name="setting">The property which is currently animated.</param>
        internal ValueUpdateResult OnAnimatedPropertyValueChanged(AnimatedPropertySetting setting)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(setting.Property, false);

            if (propVal == null)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            return(this.UpdateValueCore(propVal));
        }
Beispiel #28
0
        internal AnimatedPropertySetting GetCurrentAnimation(RadProperty property)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(property, false);

            if (entry == null)
            {
                return((AnimatedPropertySetting)null);
            }
            return(this.GetCurrentAnimation(entry));
        }
Beispiel #29
0
        internal void SetPropertyValueSetAtDesignTime(RadProperty property)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(property, false);

            if (entry == null)
            {
                return;
            }
            entry.IsSetAtDesignTime = true;
        }
Beispiel #30
0
        public ValueSource GetValueSource(RadProperty property)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(property, true);

            if (entry.ValueSource == ValueSource.Unknown)
            {
                entry.ComposeCurrentValue();
            }
            return(entry.ValueSource);
        }