/// <summary>
        /// Clears the local value of a property
        /// </summary>
        public void ClearValue(DependencyProperty dp)
        {
            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dp, false /*don't create*/, out storage))
            {
                INTERNAL_PropertyStore.ClearValueCommon(storage);
            }
        }
        /// <summary>
        /// Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
        /// </summary>
        /// <param name="dependencyProperty">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        /// <param name="recursively">Specifies if the inherited value must be applied to the children of this DependencyObject.</param>
        public void SetInheritedValue(DependencyProperty dependencyProperty, object value, bool recursively)
        {
            //-----------------------
            // CALL "SET INHERITED VALUE" ON THE STORAGE:
            //-----------------------
            var storage = INTERNAL_PropertyStore.GetInheritedPropertyStorage(this, dependencyProperty, createAndSaveNewStorageIfNotExists: true);

            INTERNAL_PropertyStore.SetInheritedValue(storage, value, recursively);
        }
        /// <summary>
        /// Sets a value that states that the visuals do not reflect the value of the Dependency in C#, so the visuals should be updated even if the value doesn't change the next time it is set.
        /// </summary>
        /// <param name="dp">The DependencyProperty that needs its visual's equivalents refreshed.</param>
        internal void DirtyVisualValue(DependencyProperty dp)
        {
            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dp, true /*create if not found*/, out storage))
            {
                INTERNAL_PropertyStore.DirtyVisualValue(storage);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
        /// </summary>
        /// <param name="dependencyProperty">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        /// <param name="recursively">Specifies if the inherited value must be applied to the children of this DependencyObject.</param>
        public void SetInheritedValue(DependencyProperty dependencyProperty, object value, bool recursively)
        {
            //-----------------------
            // CALL "SET INHERITED VALUE" ON THE STORAGE:
            //-----------------------
            var storage = INTERNAL_PropertyStore.GetInheritedPropertyStorageOrCreateNewIfNotFound(this, dependencyProperty);

            INTERNAL_PropertyStore.SetInheritedValue(storage, value, recursively);
        }
        internal void SetLocalStyleValue(DependencyProperty dp, object value)
        {
            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dp, value != DependencyProperty.UnsetValue /*create*/, out storage))
            {
                INTERNAL_PropertyStore.SetLocalStyleValue(storage, value);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Returns the current effective value of a dependency property from a DependencyObject.
        /// </summary>
        /// <param name="dependencyProperty">
        /// The DependencyProperty identifier of the property for which to retrieve the
        /// value.
        /// </param>
        /// <returns>Returns the current effective value.</returns>
        public object GetValue(DependencyProperty dependencyProperty)
        {
            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dependencyProperty, false /*don't create*/, out storage))
            {
                return(INTERNAL_PropertyStore.GetEffectiveValue(storage));
            }
            return(dependencyProperty.GetTypeMetaData(this.GetType()).DefaultValue);
        }
Beispiel #7
0
        // This method is here to workaround the fact that in Silverlight, ReadLocalValue()
        // can return a value set from a style if it is a BindingExpression, while in WPF
        // ReadLocalValue() will only return the local value
        internal object ReadLocalValueInternal(DependencyProperty dp)
        {
            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dp, false /*don't create*/, out storage))
            {
                return(storage.LocalValue);
            }
            return(DependencyProperty.UnsetValue);
        }
Beispiel #8
0
        /// <summary>
        /// Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
        /// </summary>
        /// <param name="dp">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        /// <param name="recursively">Specifies if the inherited value must be applied to the children of this DependencyObject.</param>
        internal void SetInheritedValue(DependencyProperty dp, object value, bool recursively)
        {
            //-----------------------
            // CALL "SET INHERITED VALUE" ON THE STORAGE:
            //-----------------------
            INTERNAL_PropertyStorage storage;

            INTERNAL_PropertyStore.TryGetInheritedPropertyStorage(this, dp, true /*create*/, out storage);
            INTERNAL_PropertyStore.SetInheritedValue(storage, value, recursively);
        }
        public object GetAnimationValue(DependencyProperty dependencyProperty)
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            var storage = INTERNAL_PropertyStore.GetStorage(this, dependencyProperty, createAndSaveNewStorageIfNotExists: true);

            return(INTERNAL_PropertyStore.GetValue(storage));
        }
Beispiel #10
0
        public void SetAnimationValue(DependencyProperty dependencyProperty, object value)
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            var storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, dependencyProperty);

            INTERNAL_PropertyStore.SetSpecificValue(storage, KindOfValue.Animated, value);
        }
Beispiel #11
0
        /// <summary>
        /// Sets the local value of a dependency property on a DependencyObject while not overriding a hypothetical Binding (example: when the user writes in a TextBox with a two way Binding on its Text property).
        /// </summary>
        /// <param name="dependencyProperty">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        public void SetLocalValue(DependencyProperty dependencyProperty, object value)
        {
#if PERFSTAT
            var t = Performance.now();
#endif
            var storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, dependencyProperty);
#if PERFSTAT
            Performance.Counter("DependencyObject.SetLocalValue", t);
#endif
            INTERNAL_PropertyStore.SetSpecificValue(storage, KindOfValue.Local, value);
        }
Beispiel #12
0
        internal void StyleSetterValueChanged(object sender, RoutedEventArgs e)
        {
            Setter setter = (Setter)sender;

            if (setter.Property != null) // Note: it can be null for example in the XAML text editor during design time, because the "DependencyPropertyConverter" class returns "null".
            {
                INTERNAL_PropertyStorage storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, setter.Property);
                HashSet2 <Style>         stylesAlreadyVisited = new HashSet2 <Style>(); // Note: "stylesAlreadyVisited" is here to prevent an infinite recursion.
                INTERNAL_PropertyStore.SetLocalStyleValue(storage, Style.GetActiveValue(setter.Property, stylesAlreadyVisited));
            }
        }
Beispiel #13
0
        /// <summary>
        /// Sets the local value of a dependency property on a DependencyObject while not overriding a hypothetical Binding (example: when the user writes in a TextBox with a two way Binding on its Text property).
        /// </summary>
        /// <param name="dependencyProperty">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        public void SetLocalValue(DependencyProperty dependencyProperty, object value)
        {
#if PERFSTAT
            var t = Performance.now();
#endif
            var storage = INTERNAL_PropertyStore.GetStorage(this, dependencyProperty, createAndSaveNewStorageIfNotExists: true);
#if PERFSTAT
            Performance.Counter("DependencyObject.SetLocalValue", t);
#endif
            INTERNAL_PropertyStore.SetLocalValue(storage, value);
        }
Beispiel #14
0
        internal void StyleSetterValueChanged(object sender, RoutedEventArgs e)
        {
            Setter setter = (Setter)sender;

            if (setter.Property != null)                                                                                                               // Note: it can be null for example in the XAML text editor during design time, because the "DependencyPropertyConverter" class returns "null".
            {
                INTERNAL_PropertyStorage storage = INTERNAL_PropertyStore.GetStorage(this, setter.Property, createAndSaveNewStorageIfNotExists: true); //the createAndSaveNewStorageIfNotExists's value should have no actual meaning here because the PropertyStorage should have been created when applying the style.
                HashSet2 <Style>         stylesAlreadyVisited = new HashSet2 <Style>();                                                                // Note: "stylesAlreadyVisited" is here to prevent an infinite recursion.
                INTERNAL_PropertyStore.SetLocalStyleValue(storage, Style.GetActiveValue(setter.Property, stylesAlreadyVisited));
            }
        }
Beispiel #15
0
        public object GetVisualStateValue(DependencyProperty dependencyProperty) //todo: see if this is actually useful (to get specifically the VisualStateValue) and if so, change the GetValue into a GetVisualStateValue at the "return" line.
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            var storage = INTERNAL_PropertyStore.GetStorage(this, dependencyProperty, createAndSaveNewStorageIfNotExists: true);

            return(INTERNAL_PropertyStore.GetValue(storage));
        }
Beispiel #16
0
        public void SetVisualStateValue(DependencyProperty dependencyProperty, object value)
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            var storage = INTERNAL_PropertyStore.GetStorage(this, dependencyProperty, createAndSaveNewStorageIfNotExists: true);

            INTERNAL_PropertyStore.SetVisualStateValue(storage, value);
        }
Beispiel #17
0
        public void SetAnimationValue(DependencyProperty dependencyProperty, object value)
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            INTERNAL_PropertyStorage storage;

            INTERNAL_PropertyStore.TryGetStorage(this, dependencyProperty, true /*create*/, out storage);
            INTERNAL_PropertyStore.SetAnimationValue(storage, value);
        }
Beispiel #18
0
        public object GetVisualStateValue(DependencyProperty dependencyProperty) //todo: see if this is actually useful (to get specifically the VisualStateValue) and if so, change the GetValue into a GetVisualStateValue at the "return" line.
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            var storage = INTERNAL_PropertyStore.GetStorageIfExists(this, dependencyProperty);
            PropertyMetadata typeMetadata = dependencyProperty.GetTypeMetaData(this.GetType());

            return(INTERNAL_PropertyStore.GetValue(storage, typeMetadata));
        }
Beispiel #19
0
        public object GetAnimationValue(DependencyProperty dependencyProperty)
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            var storage = INTERNAL_PropertyStore.GetStorageIfExists(this, dependencyProperty);
            PropertyMetadata typeMetadata = dependencyProperty.GetTypeMetaData(this.GetType());

            return(INTERNAL_PropertyStore.GetValue(storage, typeMetadata));
        }
Beispiel #20
0
        public void CoerceValue(DependencyProperty dp)
        {
            if (dp == null)
            {
                throw new ArgumentNullException("No property specified.");
            }

            INTERNAL_PropertyStorage storage;

            INTERNAL_PropertyStore.TryGetStorage(this, dp, true /*create*/, out storage);
            INTERNAL_PropertyStore.CoerceValueCommon(storage);
        }
Beispiel #21
0
        /// <summary>
        /// Returns the local value of a dependency property, if a local value is set.
        /// </summary>
        /// <param name="dependencyProperty">
        /// The DependencyProperty identifier of the property for which to retrieve the
        /// local value.
        /// </param>
        /// <returns>
        /// Returns the local value, or returns the sentinel value UnsetValue if no local
        /// value is set.
        /// </returns>
        public object ReadLocalValue(DependencyProperty dependencyProperty)
        {
            var storage = INTERNAL_PropertyStore.GetStorageIfExists(this, dependencyProperty);

            if (storage != null)
            {
                return(storage.Local);
            }
            else
            {
                return(INTERNAL_NoValue.NoValue);
            }
        }
Beispiel #22
0
 internal void ResetInheritedProperties()
 {
     foreach (DependencyProperty property in INTERNAL_AllInheritedProperties.Keys)
     {
         INTERNAL_PropertyStorage storage;
         if (INTERNAL_PropertyStorageDictionary.TryGetValue(property, out storage))
         {
             INTERNAL_PropertyStore.ResetInheritedValue(storage);
             INTERNAL_PropertyStorageDictionary.Remove(property);
         }
     }
     INTERNAL_AllInheritedProperties.Clear();
 }
Beispiel #23
0
        public void SetValue(DependencyProperty dp, object value)
        {
            // Verify the arguments:
            if (dp == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            INTERNAL_PropertyStorage storage;

            INTERNAL_PropertyStore.TryGetStorage(this, dp, true /*create*/, out storage);
            INTERNAL_PropertyStore.SetValueCommon(storage, value, false);
        }
Beispiel #24
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            if (this.BorderBrush == null)
            {
                INTERNAL_PropertyStore.ApplyCssChanges(null, null, Border.BorderBrushProperty.GetMetadata(typeof(Border)), this);
            }

#if REWORKLOADED
            this.AddVisualChild(this._child);
#else
            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_child, this);
#endif
        }
Beispiel #25
0
 internal void ResetInheritedProperties()
 {
     if (INTERNAL_AllInheritedProperties != null)
     {
         foreach (DependencyProperty property in INTERNAL_AllInheritedProperties.Keys)
         {
             if (INTERNAL_PropertyStorageDictionary.ContainsKey(property))
             {
                 INTERNAL_PropertyStore.ResetInheritedValue(INTERNAL_PropertyStorageDictionary[property]);
             }
         }
         INTERNAL_AllInheritedProperties.Clear();
     }
 }
Beispiel #26
0
        internal List <DependencyProperty> INTERNAL_PropertiesForWhichToCallPropertyChangedWhenLoadedIntoVisualTree; // When a UI element is added to the Visual Tree, we call "PropertyChanged" on all its set properties so that the control can refresh itself. However, when a property is not set, we don't call PropertyChanged. Unless the property is listed here.

        /// <summary>
        /// Returns the current effective value of a dependency property from a DependencyObject.
        /// </summary>
        /// <param name="dependencyProperty">
        /// The DependencyProperty identifier of the property for which to retrieve the
        /// value.
        /// </param>
        /// <returns>Returns the current effective value.</returns>
        public object GetValue(DependencyProperty dependencyProperty)
        {
//#if PERFSTAT
//          var t = Performance.now();
//#endif
            var storage = INTERNAL_PropertyStore.GetStorageIfExists(this, dependencyProperty);
            PropertyMetadata typeMetadata = dependencyProperty.GetTypeMetaData(this.GetType());
            var tmp = INTERNAL_PropertyStore.GetValue(storage, typeMetadata);

//#if PERFSTAT
//          Performance.Counter("DependencyObject.GetValue [" + dependencyProperty.Name + "]", t);
//#endif
            return(tmp);
        }
Beispiel #27
0
        public object GetVisualStateValue(DependencyProperty dependencyProperty) //todo: see if this is actually useful (to get specifically the VisualStateValue) and if so, change the GetValue into a GetVisualStateValue at the "return" line.
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }
            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dependencyProperty, false /*don't create*/, out storage))
            {
                return(storage.AnimatedValue);
            }
            return(dependencyProperty.GetTypeMetaData(this.GetType()).DefaultValue);
        }
Beispiel #28
0
        internal List <DependencyProperty> INTERNAL_PropertiesForWhichToCallPropertyChangedWhenLoadedIntoVisualTree; // When a UI element is added to the Visual Tree, we call "PropertyChanged" on all its set properties so that the control can refresh itself. However, when a property is not set, we don't call PropertyChanged. Unless the property is listed here.

        /// <summary>
        /// Returns the current effective value of a dependency property from a DependencyObject.
        /// </summary>
        /// <param name="dependencyProperty">
        /// The DependencyProperty identifier of the property for which to retrieve the
        /// value.
        /// </param>
        /// <returns>Returns the current effective value.</returns>
        public object GetValue(DependencyProperty dependencyProperty)
        {
//#if PERFSTAT
//            var t = Performance.now();
//#endif
            var storage = INTERNAL_PropertyStore.GetStorage(this, dependencyProperty);
            //return dependencyProperty.Store.GetValue(storage);

            var tmp = INTERNAL_PropertyStore.GetValue(storage);

//#if PERFSTAT
//            Performance.Counter("DependencyObject.GetValue [" + dependencyProperty.Name + "]", t);
//#endif
            return(tmp);
        }
Beispiel #29
0
        public object GetAnimationValue(DependencyProperty dependencyProperty)
        {
            if (dependencyProperty == null)
            {
                throw new ArgumentNullException("No property specified");
            }

            INTERNAL_PropertyStorage storage;

            if (INTERNAL_PropertyStore.TryGetStorage(this, dependencyProperty, false /*don't create*/, out storage))
            {
                return(storage.AnimatedValue);
            }
            return(dependencyProperty.GetTypeMetaData(this.GetType()).DefaultValue);
        }
Beispiel #30
0
        internal override void OnAttached(DependencyObject target)
        {
            if (IsAttached)
            {
                return;
            }
            base.OnAttached(target);
            var source = FindSource();

            PropertyPathWalker.Update(source); //FindSource should find the source now. Otherwise, the PropertyPathNodes shoud do the work (their properties will change when the source will become available)

            if (ParentBinding.Mode == BindingMode.TwoWay)
            {
                PropertyListener = INTERNAL_PropertyStore.ListenToChanged(Target, Property, UpdateSourceCallback);
            }
        }