internal void ResetInheritableProperties()
        {
            if (this.entries.Count == 0)
            {
                return;
            }
            List <RadPropertyValue> radPropertyValueList = new List <RadPropertyValue>((IEnumerable <RadPropertyValue>) this.entries.Values);
            int count = radPropertyValueList.Count;

            for (int index = 0; index < count; ++index)
            {
                RadPropertyValue propVal = radPropertyValueList[index];
                if (propVal.Metadata.IsInherited && propVal.InvalidateInheritedValue())
                {
                    int num = (int)this.owner.UpdateValueCore(propVal);
                }
            }
        }
        internal void ResetInheritableProperties()
        {
            if (this.entries.Count == 0)
            {
                return;
            }

            //copy values in separate list as the Reset process may change the collection
            List <RadPropertyValue> values = new List <RadPropertyValue>(this.entries.Values);
            int length = values.Count;

            for (int i = 0; i < length; i++)
            {
                RadPropertyValue propVal = values[i];
                if (propVal.Metadata.IsInherited && propVal.InvalidateInheritedValue())
                {
                    this.owner.UpdateValueCore(propVal);
                }
            }
        }
Пример #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);
        }
Пример #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);
        }