Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        protected virtual ValueUpdateResult SetValueCore(
            RadPropertyValue propVal,
            object propModifier,
            object newValue,
            ValueSource source)
        {
            if (this.GetBitState(1L) || this.GetBitState(2L))
            {
                return(ValueUpdateResult.Canceled);
            }
            object           currentValue    = propVal.GetCurrentValue(false);
            ValueSource      valueSource     = propVal.ValueSource;
            RadPropertyValue source1         = (RadPropertyValue)null;
            bool             isUpdatingValue = propVal.IsUpdatingValue;

            if (!propVal.IsCompositionLocked && this.IsPropertyCancelable(propVal.Metadata))
            {
                source1 = new RadPropertyValue(propVal);
            }
            propVal.BeginUpdate(true, true);
            switch (source)
            {
            case ValueSource.DefaultValue:
            case ValueSource.DefaultValueOverride:
                propVal.SetDefaultValueOverride(newValue);
                break;

            case ValueSource.Inherited:
                propVal.InvalidateInheritedValue();
                break;

            case ValueSource.Style:
                if (!isUpdatingValue)
                {
                    this.RemoveAnimation(propVal);
                }
                propVal.SetStyle((IPropertySetting)propModifier);
                break;

            case ValueSource.Local:
                propVal.SetLocalValue(newValue);
                break;

            case ValueSource.PropertyBinding:
                if (!isUpdatingValue)
                {
                    this.RemoveBinding(propVal);
                }
                propVal.SetBinding((PropertyBinding)propModifier);
                break;

            case ValueSource.LocalFromBinding:
                propVal.SetLocalValueFromBinding(newValue);
                break;

            case ValueSource.Animation:
                if (!isUpdatingValue)
                {
                    this.RemoveAnimation(propVal);
                }
                propVal.SetAnimation((AnimatedPropertySetting)propModifier);
                break;
            }
            propVal.EndUpdate(true, true);
            if (propVal.IsCompositionLocked)
            {
                return(ValueUpdateResult.Updating);
            }
            ValueUpdateResult valueUpdateResult = this.RaisePropertyNotifications(propVal, currentValue, propVal.GetCurrentValue(true), valueSource);

            if (valueUpdateResult == ValueUpdateResult.Canceled && source1 != null)
            {
                propVal.Copy(source1);
            }
            source1?.Dispose();
            return(valueUpdateResult);
        }
Exemple #4
0
        /// <summary>
        /// Performs the core logic of updating property value.
        /// </summary>
        /// <param name="propVal">The property value structure, holding property information.</param>
        /// <param name="propModifier">Additional modifier, like IPropertySetting</param>
        /// <param name="newValue">The actual new value to be set, valid for Local and DefaultValue sources.</param>
        /// <param name="source">Specifies the source of the provided new value.</param>
        /// <returns>The result of the operation.</returns>
        protected virtual ValueUpdateResult SetValueCore(RadPropertyValue propVal, object propModifier, object newValue, ValueSource source)
        {
            //do not set anything while disposing
            if (this.GetBitState(DisposingStateKey) || this.GetBitState(DisposedStateKey))
            {
                return(ValueUpdateResult.Canceled);
            }

            object      oldValue  = propVal.GetCurrentValue(false);
            ValueSource oldSource = propVal.ValueSource;

            RadPropertyValue oldPropState  = null;
            bool             updatingValue = propVal.IsUpdatingValue;

            if (!propVal.IsCompositionLocked && this.IsPropertyCancelable(propVal.Metadata))
            {
                //create a copy of the current property value
                //so that we may restore it later if property change is not accepted
                oldPropState = new RadPropertyValue(propVal);
            }
            //perform value update
            propVal.BeginUpdate(true, true);

            switch (source)
            {
            case ValueSource.Animation:
                if (!updatingValue)
                {
                    this.RemoveAnimation(propVal);
                }
                propVal.SetAnimation((AnimatedPropertySetting)propModifier);
                break;

            case ValueSource.DefaultValue:
            case ValueSource.DefaultValueOverride:
                propVal.SetDefaultValueOverride(newValue);
                break;

            case ValueSource.Local:
                propVal.SetLocalValue(newValue);
                break;

            case ValueSource.LocalFromBinding:
                propVal.SetLocalValueFromBinding(newValue);
                break;

            case ValueSource.PropertyBinding:
                if (!updatingValue)
                {
                    RemoveBinding(propVal);
                }
                propVal.SetBinding((PropertyBinding)propModifier);
                break;

            case ValueSource.Style:
                if (!updatingValue)
                {
                    this.RemoveAnimation(propVal);
                }
                propVal.SetStyle((IPropertySetting)propModifier);
                break;

            case ValueSource.Inherited:
                propVal.InvalidateInheritedValue();
                break;

            default:
                Debug.Assert(false, "Invalid value source");
                break;
            }

            propVal.EndUpdate(true, true);
            //are we still in a process of updating?
            if (propVal.IsCompositionLocked)
            {
                return(ValueUpdateResult.Updating);
            }

            ValueUpdateResult result = this.RaisePropertyNotifications(propVal, oldValue, propVal.GetCurrentValue(true), oldSource);

            if (result == ValueUpdateResult.Canceled && oldPropState != null)
            {
                //restore previous state as operation was canceled
                propVal.Copy(oldPropState);
            }

            return(result);
        }