Exemplo n.º 1
0
 /// <summary>
 /// Updates the binding source property.
 /// </summary>
 /// <param name="boundProperty"></param>
 /// <param name="newValue"></param>
 public void UpdateBindingSourceProperty(RadProperty boundProperty, object newValue)
 {
     if (this.options == PropertyBindingOptions.TwoWay)
     {
         this.BindingSourceObject.SetValue(toProperty, newValue);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the RadPropertyBinding class.
 /// </summary>
 /// <param name="bindingSourceObject"></param>
 /// <param name="fromProperty"></param>
 /// <param name="bindingSourceProperty"></param>
 /// <param name="options"></param>
 public RadPropertyBinding(RadObject bindingSourceObject, RadProperty fromProperty, RadProperty bindingSourceProperty, PropertyBindingOptions options)
 {
     this.bindingSourceObject = bindingSourceObject;
     this.fromProperty        = fromProperty;
     this.toProperty          = bindingSourceProperty;
     this.options             = options;
 }
Exemplo n.º 3
0
        public static object Deserialize(string fullName, string propertyName, string value)
        {
            if (PropertyReader.directConverters.ContainsKey(propertyName))
            {
                return(PropertyReader.directConverters[propertyName](value));
            }
            if (PropertyReader.typeDescriptorConverters.ContainsKey(propertyName))
            {
                return(PropertyReader.typeDescriptorConverters[propertyName].Converter?.ConvertFromString((ITypeDescriptorContext)null, PropertyReader.serializationCulture, value));
            }
            object obj = (object)null;

            try
            {
                RadProperty property = XmlPropertySetting.DeserializePropertySafe(!string.IsNullOrEmpty(fullName) ? fullName : propertyName);
                if (property != null)
                {
                    obj = XmlPropertySetting.DeserializeValue(property, value);
                }
            }
            catch
            {
            }
            return(obj);
        }
Exemplo n.º 4
0
 internal void Dispose()
 {
     ++this.lockComposeCount;
     ++this.lockValueUpdateCount;
     if (this.owner != null)
     {
         this.owner.RemoveBinding(this);
     }
     if (this.boundObjects != null)
     {
         for (int index = this.boundObjects.Count - 1; index >= 0; --index)
         {
             PropertyBoundObject boundObject = this.boundObjects[index];
             RadObject           radObject   = boundObject.Object;
             if (radObject != null && !radObject.IsDisposed && !radObject.IsDisposing)
             {
                 int num = (int)radObject.UnbindProperty(boundObject.Property);
             }
         }
         this.boundObjects.Clear();
     }
     this.property         = (RadProperty)null;
     this.metadata         = (RadPropertyMetadata)null;
     this.owner            = (RadObject)null;
     this.propertyBinding  = (PropertyBinding)null;
     this.animationSetting = (AnimatedPropertySetting)null;
     this.styleSetting     = (IPropertySetting)null;
 }
        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);
        }
Exemplo n.º 6
0
        private static RadProperty RegisterCommon(string name, Type propertyType, Type ownerType, AttachedPropertyUsage usage, RadPropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback)
        {
            RadProperty.FromNameKey key1 = new RadProperty.FromNameKey(name, ownerType);
            lock (RadProperty.Synchronized)
            {
                if (RadProperty.PropertyFromName.Contains(key1))
                {
                    object[] objArray1 = new object[] { name, ownerType.Name };
                    throw new ArgumentException(string.Format("Property already registered", objArray1));
                }
            }
            if (defaultMetadata == null)
            {
                defaultMetadata = RadProperty.AutoGeneratePropertyMetadata(propertyType, validateValueCallback, name, ownerType);
            }
            else
            {
                if (!defaultMetadata.DefaultValueWasSet())
                {
                    defaultMetadata.DefaultValue = RadProperty.AutoGenerateDefaultValue(propertyType);
                }
                //TODO:
                //RadProperty.ValidateMetadataDefaultValue(defaultMetadata, propertyType, validateValueCallback);
            }
            defaultMetadata.SetAttachedPropertyUsage(usage);
            RadProperty property1 = new RadProperty(name, propertyType, ownerType, defaultMetadata, validateValueCallback);

            defaultMetadata.Seal(property1, null);
            lock (RadProperty.Synchronized)
            {
                RadProperty.PropertyFromName[key1] = property1;
            }

            return(property1);
        }
Exemplo n.º 7
0
 private void SetupOverrideMetadata(Type forType, RadPropertyMetadata typeMetadata, out RadObjectType dType, out RadPropertyMetadata baseMetadata)
 {
     if (forType == null)
     {
         throw new ArgumentNullException("forType");
     }
     if (typeMetadata == null)
     {
         throw new ArgumentNullException("typeMetadata");
     }
     if (typeMetadata.Sealed)
     {
         throw new ArgumentException(string.Format("TypeMetadataAlreadyInUse", new object[0]));
     }
     if (!typeof(RadObject).IsAssignableFrom(forType))
     {
         object[] objArray1 = new object[] { forType.Name };
         throw new ArgumentException(string.Format("TypeMustBeRadObjectDerived {0}", objArray1));
     }
     if (typeMetadata.IsDefaultValueModified)
     {
         RadProperty.ValidateMetadataDefaultValue(typeMetadata, this.PropertyType, this.ValidateValueCallback);
     }
     dType        = RadObjectType.FromSystemType(forType);
     baseMetadata = this.GetMetadata(dType.BaseType);
     if (!baseMetadata.GetType().IsAssignableFrom(typeMetadata.GetType()))
     {
         throw new ArgumentException(string.Format("OverridingMetadataDoesNotMatchBaseMetadataType", new object[0]));
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the RadPropertyBinding class.
 /// </summary>
 /// <param name="sourceObject"></param>
 /// <param name="boundProperty"></param>
 /// <param name="sourceProperty"></param>
 /// <param name="options"></param>
 public PropertyBinding(RadObject sourceObject, RadProperty boundProperty, RadProperty sourceProperty, PropertyBindingOptions options)
 {
     this.sourceObject   = new WeakReference(sourceObject);
     this.boundProperty  = boundProperty;
     this.sourceProperty = sourceProperty;
     this.options        = options;
 }
Exemplo n.º 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);
                }
            }
        }
 public RadPropertyChangingEventArgs(RadProperty property, object oldValue, object newValue, RadPropertyMetadata metadata)
 {
     this.property = property;
     this.oldValue = oldValue;
     this.newValue = newValue;
     this.metadata = metadata;
 }
Exemplo n.º 11
0
        public static RadProperty FindProperty(
            Type currentType,
            string propertyName,
            bool fallback)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                return((RadProperty)null);
            }
            string[] strArray = propertyName.Split('.');
            if (strArray.Length > 1)
            {
                propertyName = strArray[strArray.Length - 1];
            }
            RadProperty safe = RadProperty.FindSafe(currentType, propertyName);

            if (safe == null && fallback)
            {
                for (currentType = currentType.BaseType; (object)currentType != null && (object)currentType != (object)typeof(RadObject); currentType = currentType.BaseType)
                {
                    safe = RadProperty.FindSafe(currentType, propertyName);
                    if (safe == null && (currentType.Name == "LightVisualElement" || currentType.Name == "UIChartElement"))
                    {
                        safe = RadProperty.FindSafe(currentType, "Border" + propertyName);
                    }
                    if (safe != null)
                    {
                        break;
                    }
                }
            }
            return(safe);
        }
        private List <IPropertyChangeListener> GetPropertyChangeListeners(RadProperty radProperty)
        {
            List <IPropertyChangeListener> changeListeners;

            elementPropertyChangeListeners.TryGetValue(radProperty.PropertyKey, out changeListeners);
            return(changeListeners);
        }
Exemplo n.º 13
0
        public void ApplyValue(RadObject element)
        {
            string propertyName = this.Name;

            if (this.PropertyMapper != null)
            {
                propertyName = this.PropertyMapper(propertyName, element);
            }
            if (this.property == null)
            {
                this.property = PropertySetting.FindProperty(element.GetType(), propertyName, true);
            }
            if (this.property != null && (!this.property.OwnerType.IsAssignableFrom(element.GetType()) || this.property.Name != propertyName))
            {
                this.property = PropertySetting.FindProperty(element.GetType(), propertyName, true);
            }
            if (this.property == null)
            {
                return;
            }
            if (this.endValue != null)
            {
                if (this.animatedSetting == null)
                {
                    this.animatedSetting            = new AnimatedPropertySetting();
                    this.animatedSetting.Property   = this.property;
                    this.animatedSetting.StartValue = this.value;
                    this.animatedSetting.EndValue   = this.endValue;
                }
                this.animatedSetting.IsStyleSetting = true;
                this.animatedSetting.Property       = this.property;
                this.animatedSetting.ApplyValue(element);
            }
            int num = (int)element.AddStylePropertySetting((IPropertySetting)this);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        private IPropertySetting MapProperty(
            PropertySettingCollection.InheritedSetting inheritedSetting,
            RadElement element)
        {
            if (element == null)
            {
                return((IPropertySetting)null);
            }
            RadProperty property = element.MapStyleProperty(inheritedSetting.property, inheritedSetting.settingType);

            if (property == null)
            {
                return((IPropertySetting)null);
            }
            PropertySettingCollection.InheritedSetting key = new PropertySettingCollection.InheritedSetting(inheritedSetting.settingType, property);
            IPropertySetting propertySetting;

            if (!this.mappedSettings.TryGetValue(key, out propertySetting))
            {
                lock (Locker.SyncObj)
                {
                    if (!this.mappedSettings.TryGetValue(key, out propertySetting))
                    {
                        propertySetting.Property = property;
                        this.mappedSettings[key] = propertySetting;
                    }
                }
            }
            return(propertySetting);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
 public AnimatedPropertySetting(RadProperty property, int frames, int interval, object step)
 {
     this.property = property;
     this.frames   = frames;
     this.interval = interval;
     this.step     = step;
 }
Exemplo n.º 19
0
        private IPropertySetting MapProperty(InheritedSetting inheritedSetting, RadElement element)
        {
            if (element == null)
            {
                return(null);
            }
            RadProperty mappedProperty = element.MapStyleProperty(inheritedSetting.property, inheritedSetting.settingType);

            if (mappedProperty == null)
            {
                return(null);
            }

            InheritedSetting newInheritedSetting = new InheritedSetting(inheritedSetting.settingType, mappedProperty);
            IPropertySetting newSetting;

            if (!mappedSettings.TryGetValue(newInheritedSetting, out newSetting))
            {
                lock (Locker.SyncObj)
                {
                    //double check concurrency pattern
                    if (!mappedSettings.TryGetValue(newInheritedSetting, out newSetting))
                    {
                        newSetting          = inheritedSetting.setting.Clone() as IPropertySetting;
                        newSetting.Property = mappedProperty;
                        mappedSettings[newInheritedSetting] = newSetting;
                    }
                }
            }

            return(newSetting);
        }
Exemplo n.º 20
0
 public ThemeSettingOverride(RadProperty property, object value, string visualState)
 {
     this.property        = property;
     this.visualState     = visualState;
     this.value           = value;
     this.propertySetting = new PropertySetting(this.property, this.value);
 }
Exemplo n.º 21
0
        public RadPropertyMetadata Copy(RadProperty dp)
        {
            RadPropertyMetadata instance = this.CreateInstance();

            instance.InvokeMerge(this, dp);
            return(instance);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 protected object GetConvertedValue(RadProperty property, object value)
 {
     if (value != null &&
         !property.PropertyType.IsAssignableFrom(value.GetType()) &&
         !(value is Telerik.WinControls.Styles.PropertySettings.IValueProvider))
     {
         try
         {
             return(Convert.ChangeType(value, property.PropertyType));
         }
         catch (Exception ex)
         {
             throw new InvalidCastException(
                       string.Format(
                           "Error changing object type during deserialization. Property {0} of type: {1}, value type: {2}",
                           property.FullName,
                           property.PropertyType,
                           value.GetType().Name
                           ),
                       ex);
         }
     }
     else
     {
         return(value);
     }
 }
Exemplo n.º 25
0
 internal RadPropertyChangedEventArgs(RadProperty property, RadPropertyMetadata metadata, object oldValue, object newValue, bool isOldValueDeferred, bool isNewValueDeferred, ValueSource oldValueSource, ValueSource newValueSource)
     : this(property, metadata, oldValue, newValue)
 {
     this._isOldValueDeferred = isOldValueDeferred;
     this._isNewValueDeferred = isNewValueDeferred;
     this._oldValueSource     = oldValueSource;
     this._newValueSource     = newValueSource;
 }
Exemplo n.º 26
0
 private static RadPropertyMetadata AutoGeneratePropertyMetadata(
     Type propertyType,
     ValidateValueCallback validateValueCallback,
     string name,
     Type ownerType)
 {
     return(new RadPropertyMetadata(RadProperty.AutoGenerateDefaultValue(propertyType)));
 }
Exemplo n.º 27
0
 public static RadProperty Register(
     string name,
     Type propertyType,
     Type ownerType,
     RadPropertyMetadata typeMetadata)
 {
     return(RadProperty.Register(name, propertyType, ownerType, typeMetadata, (ValidateValueCallback)null));
 }
Exemplo n.º 28
0
 public RadProperty GetDeserializedProperty()
 {
     if (this.tempPoroperty == null)
     {
         this.tempPoroperty = XmlPropertySetting.DeserializeProperty(this.Property);
     }
     return(this.tempPoroperty);
 }
Exemplo n.º 29
0
 internal void InvokeMerge(RadPropertyMetadata baseMetadata, RadProperty dp)
 {
     if (baseMetadata.ReadOnly)
     {
         this._readOnlyKey = baseMetadata._readOnlyKey;
     }
     this.Merge(baseMetadata, dp);
 }
 internal RadPropertyChangedEventArgs(
     RadProperty property,
     RadPropertyMetadata metadata,
     object value)
     : this(property, metadata, value, value)
 {
     this._isASubPropertyChange = true;
 }