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)); }
/// <summary> /// Performs the core value update logic. /// </summary> /// <param name="propVal"></param> /// <returns>The result of the operation.</returns> protected internal virtual ValueUpdateResult UpdateValueCore(RadPropertyValue propVal) { object oldValue = propVal.GetCurrentValue(false); ValueSource oldSource = propVal.ValueSource; //force re-composition of property's current value propVal.ComposeCurrentValue(); return(this.RaisePropertyNotifications(propVal, oldValue, propVal.GetCurrentValue(false), oldSource)); }
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); }
/// <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); }
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); }
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); }
/// <summary> /// Resets the specified property value, using the provided reset flags. /// </summary> /// <param name="propVal"></param> /// <param name="flags"></param> /// <returns>The result of the operation.</returns> protected internal virtual ValueUpdateResult ResetValueCore(RadPropertyValue propVal, ValueResetFlags flags) { //no flags are specified if (flags == ValueResetFlags.None) { return(ValueUpdateResult.NotUpdated); } object oldValue = propVal.GetCurrentValue(false); ValueSource oldSource = propVal.ValueSource; RadPropertyValue oldState = null; //check whether we are in nested update block if (!propVal.IsCompositionLocked) { //create a copy of the current property value oldState = new RadPropertyValue(propVal); } propVal.BeginUpdate(true, false); //update property value as specified by the provided flags if ((flags & ValueResetFlags.Animation) == ValueResetFlags.Animation) { this.SetValueCore(propVal, null, null, ValueSource.Animation); } if ((flags & ValueResetFlags.Local) == ValueResetFlags.Local) { this.SetValueCore(propVal, null, RadProperty.UnsetValue, ValueSource.Local); } if ((flags & ValueResetFlags.DefaultValueOverride) == ValueResetFlags.DefaultValueOverride) { this.SetValueCore(propVal, null, RadProperty.UnsetValue, ValueSource.DefaultValue); } if ((flags & ValueResetFlags.Binding) == ValueResetFlags.Binding) { this.SetValueCore(propVal, null, null, ValueSource.PropertyBinding); } if ((flags & ValueResetFlags.TwoWayBindingLocal) == ValueResetFlags.TwoWayBindingLocal) { this.SetValueCore(propVal, null, RadProperty.UnsetValue, ValueSource.LocalFromBinding); } if ((flags & ValueResetFlags.Style) == ValueResetFlags.Style) { this.SetValueCore(propVal, null, null, ValueSource.Style); } if ((flags & ValueResetFlags.Inherited) == ValueResetFlags.Inherited) { this.SetValueCore(propVal, null, RadProperty.UnsetValue, ValueSource.Inherited); } propVal.EndUpdate(true, false); if (propVal.IsCompositionLocked) { return(ValueUpdateResult.Updating); } ValueUpdateResult result = this.RaisePropertyNotifications(propVal, oldValue, propVal.GetCurrentValue(true), oldSource); if (result == ValueUpdateResult.Canceled) { //restore previous state as operation was canceled propVal.Copy(oldState); } return(result); }
/// <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); }
/// <summary> /// Retrieves the current value for the specified property. /// </summary> /// <param name="property"></param> /// <returns></returns> public object GetValue(RadProperty property) { RadPropertyValue propVal = this.propertyValues.GetEntry(property, true); return(propVal.GetCurrentValue(true)); }