コード例 #1
0
        public DependencyPropertyObserver(DependencyProperty dependencyProperty)
        {
            this.dependencyProperty = dependencyProperty;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);
        }
コード例 #2
0
            public TestExpression(object value, bool isReadOnly = false)
            {
                observableValue = new ObservableValue(value);
                observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

                this.isReadOnly = isReadOnly;
            }
コード例 #3
0
        public IndexPropertyObserver(Type propertyContainingType, IndexPropertyPathElement propertyPathElement, XamlNamespaces namespaces)
        {
            baseObserver = CreateBaseObserver(propertyContainingType, propertyPathElement.PropertyName);

            PropertyInfo indexPropertyInfo = baseObserver != null?baseObserver.ValueType.GetDefaultIndexProperty() :
                                                 propertyPathElement.PropertyName.IsEmpty ? propertyContainingType.GetDefaultIndexProperty() : propertyContainingType.GetInstanceProperty(propertyPathElement.PropertyName.MemberName);

            if (indexPropertyInfo == null)
            {
                throw new Granular.Exception("Property \"{0}.{1}\" does not have an indexer", propertyContainingType.Name, propertyPathElement.PropertyName.MemberName);
            }

            if (indexPropertyInfo.GetIndexParameters().Count() != propertyPathElement.IndexRawValues.Count())
            {
                throw new Granular.Exception("Invalid number of index parameters for \"{0}.{1}\"", indexPropertyInfo.DeclaringType.Name, indexPropertyInfo.Name);
            }

            indexerObserver = new ClrPropertyObserver(indexPropertyInfo, propertyPathElement.ParseIndexValues(indexPropertyInfo));
            indexerObserver.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            if (baseObserver != null)
            {
                baseObserver.ValueChanged += (sender, e) => indexerObserver.SetBaseValue(baseObserver.Value);
                indexerObserver.SetBaseValue(baseObserver.Value);
            }
        }
コード例 #4
0
            public ValueOverlapExpression()
            {
                values = new List <Tuple <object, object> >();

                observableValue = new ObservableValue();
                observableValue.ValueChanged += (sender, oldValue, newValue) => ValueChanged.Raise(this, oldValue, newValue);
            }
コード例 #5
0
 private void NotifyObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == _propertyName)
     {
         ValueChanged.Raise(this, EventArgs.Empty);
     }
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: jpbruyere/MagicCrow
 public void NotifyValueChange(string propName, object newValue)
 {
     try {
         ValueChanged.Raise(this, new ValueChangeEventArgs(propName, newValue));
     } catch (Exception ex) {
         Debug.WriteLine(propName + ";" + newValue + ";" + ex.ToString());
     }
 }
コード例 #7
0
        private void OnTargetValueChanged(object sender, ObservableValueChangedArgs e)
        {
            if (UpdateSourceTrigger == UpdateSourceTrigger.Default && isSourceUpdateMode)
            {
                UpdateSourceOnTargetChanged();
            }

            ValueChanged.Raise(this, e);
        }
コード例 #8
0
        private void OnTargetValueChanged(object sender, object oldValue, object newValue)
        {
            if (UpdateSourceTrigger == UpdateSourceTrigger.Default && isSourceUpdateMode)
            {
                UpdateSourceOnTargetChanged();
            }

            ValueChanged.Raise(this, oldValue, newValue);
        }
コード例 #9
0
        public ClrPropertyObserver(PropertyInfo propertyInfo, IEnumerable <object> index)
        {
            this.propertyInfo      = propertyInfo;
            this.propertyGetMethod = propertyInfo.GetGetMethod();
            this.propertySetMethod = propertyInfo.GetSetMethod();
            this.index             = index;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);
        }
コード例 #10
0
        /// <summary>
        /// Raises the <see cref="ValueChanged"/> event, and passes changes onto the next expression part in the chain.
        /// </summary>
        protected virtual void OnValueChanged()
        {
            ValueChanged.Raise(this, EventArgs.Empty);

            if (_nextPart != null)
            {
                //if the value of this PropertyExpressionPart changes, we need to update the Object in the next PropertyExpressionPart with the new value
                _nextPart.Object = Value;
            }
        }
コード例 #11
0
        public ResourceReferenceExpression(IResourceContainer resourceContainer, object resourceKey)
        {
            this.resourceContainer = resourceContainer;
            this.resourceKey       = resourceKey;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, oldValue, newValue) => ValueChanged.Raise(this, oldValue, newValue);
            observableValue.BaseValue     = GetResourceValue();

            resourceContainer.ResourcesChanged += OnResourcesChanged;
        }
コード例 #12
0
        public ContextSourceObserver(DependencyObject target, object baseValue)
        {
            this.target = target;

            observableValue = new ObservableValue(baseValue);
            observableValue.ValueChanged += (sender, oldValue, newValue) => ValueChanged.Raise(this, oldValue, newValue);

            if (target is IContextElement)
            {
                ((IContextElement)target).ContextParentChanged += OnTargetContextParentChanged;
            }
        }
コード例 #13
0
        public CoercedDependencyPropertyValueEntry(IDependencyPropertyValueEntry source, DependencyObject dependencyObject, CoerceValueCallback coerceValueCallback)
        {
            this.source              = source;
            this.dependencyObject    = dependencyObject;
            this.coerceValueCallback = coerceValueCallback;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            source.ValueChanged += (sender, e) => CoerceValue();
            CoerceValue();
        }
コード例 #14
0
        private void OnValueChanged(int newValuePriority, object newValue)
        {
            if (ValuePriority > newValuePriority) // a higher priority value is hiding the new value
            {
                if (baseValuePriority <= newValuePriority && newValuePriority <= BaseValueHighestPriority)
                {
                    baseValuePriority = BaseValueHighestPriority + 1; // invalidate baseValuePriority
                }

                return;
            }

            object oldValue        = Value;
            bool   isNewValueValid = IsValueValid(newValue);

            if (ValuePriority == newValuePriority && isNewValueValid && coerceValueCallback == null)
            {
                Value = newValue;
                ValueChanged.Raise(this, new DependencyPropertyChangedEventArgs(dependencyProperty, oldValue, newValue)); // since this was already the value priority and there is no coercion, Value must have been changed here
                return;
            }

            if (ValuePriority < newValuePriority && !isNewValueValid) // a higher priority value was changed but it's not valid, so it can be ignored
            {
                return;
            }

            while (!isNewValueValid && newValuePriority > 0) // try to find the highest priority value that is valid
            {
                newValuePriority--;
                newValue        = GetValue(newValuePriority, true);
                isNewValueValid = IsValueValid(newValue);
            }

            if (ValuePriority != newValuePriority)
            {
                ValuePriority     = newValuePriority;
                baseValuePriority = newValuePriority; // possible invalidation of baseValuePriority
            }

            if (coerceValueCallback != null)
            {
                newValue = coerceValueCallback(dependencyObject, newValue);
            }

            if (Granular.Compatibility.EqualityComparer.Default.Equals(oldValue, newValue))
            {
                return;
            }

            Value = newValue;
            ValueChanged.Raise(this, new DependencyPropertyChangedEventArgs(dependencyProperty, oldValue, newValue));
        }
コード例 #15
0
        public AnimationExpression(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            this.dependencyObject   = dependencyObject;
            this.dependencyProperty = dependencyProperty;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            layers = new AnimationLayerCollection();
            layers.LayerInvalidated += OnLayerInvalidated;

            SetAnimationValue();
        }
コード例 #16
0
        public DataContextSourceObserver(DependencyObject target)
        {
            this.target = target;

            frameworkElementValue = new ObservableValue(GetFrameworkElementAncestor(target));
            frameworkElementValue.ValueChanged += (sender, oldValue, newValue) => dataContextValue.SetBaseValue(newValue);

            dataContextValue = new DependencyPropertyObserver(FrameworkElement.DataContextProperty);
            dataContextValue.SetBaseValue(frameworkElementValue.Value);
            dataContextValue.ValueChanged += (sender, oldValue, newValue) => ValueChanged.Raise(this, oldValue, newValue);

            if (target is IContextElement)
            {
                ((IContextElement)target).ContextParentChanged += OnTargetContextParentChanged;
            }
        }
コード例 #17
0
        public void CoerceValue()
        {
            if (coerceValueCallback == null)
            {
                return;
            }

            object oldValue = Value;
            object newValue = coerceValueCallback(dependencyObject, GetValue(ValuePriority, true));

            if (Granular.Compatibility.EqualityComparer.Default.Equals(oldValue, newValue))
            {
                return;
            }

            Value = newValue;
            ValueChanged.Raise(this, new DependencyPropertyChangedEventArgs(dependencyProperty, oldValue, newValue));
        }
コード例 #18
0
        public DependencyPropertyValueEntry(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            this.dependencyProperty = dependencyProperty;
            this.defaultValue       = dependencyProperty.GetMetadata(dependencyObject.GetType()).DefaultValue;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            baseValues = new object[BaseValuePriorities];

            for (int i = 0; i < baseValues.Length; i++)
            {
                baseValues[i] = ObservableValue.UnsetValue;
            }

            currentValue   = ObservableValue.UnsetValue;
            animationValue = ObservableValue.UnsetValue;
        }
コード例 #19
0
        public ObservableExpression(object baseValue, PropertyPath propertyPath)
        {
            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            if (propertyPath.IsEmpty)
            {
                observableValue.Value = baseValue;
                ValueType             = baseValue != null?baseValue.GetType() : null;
            }
            else
            {
                propertyPathElement = propertyPath.Elements.Last();

                baseObserver = new ObservableExpression(baseValue, propertyPath.GetBasePropertyPath());
                baseObserver.ValueChanged += (sender, e) => SetDelegateObserverBaseValue();

                SetDelegateObserverBaseValue();
            }
        }
コード例 #20
0
 public void NotifyValueChanged(string name, object value)
 {
     ValueChanged.Raise(this, new ValueChangeEventArgs(name, value));
 }
コード例 #21
0
 /// <summary>
 /// Raises the <see cref="E:Sce.Atf.Controls.NumericTupleControl.ValueChanged"/> event</summary>
 /// <param name="e">Event args</param>
 protected virtual void OnValueChanged(EventArgs e)
 {
     ValueChanged.Raise(this, e);
 }
コード例 #22
0
 private void OnObservableValueChanged(object sender, ObservableValueChangedArgs e)
 {
     ValueChanged.Raise(this, e);
 }
コード例 #23
0
 /// <summary>
 /// Raises this object's <see cref="ValueChanged"/> event
 /// </summary>
 /// <param name="e"></param>
 protected void OnValueChanged(ValueChangedEventArgs e)
 {
     ValueChanged.Raise(this, e);
 }
コード例 #24
0
 public ReadOnlyObservableValue(IObservableValue source)
 {
     this.source          = source;
     source.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);
 }
コード例 #25
0
 /// <summary>
 /// Raises the ValueChanged event and performs custom processing</summary>
 protected virtual void OnValueChanged()
 {
     ValueChanged.Raise(this, EventArgs.Empty);
 }
コード例 #26
0
 /// <summary>
 /// Helper function to raise the value changed event
 /// </summary>
 public virtual void NotifyValueChanged(string MemberName, object _value)
 {
     //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value);
     ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
 }
コード例 #27
0
 private void OnPropertyValueChanged(object sender, EventArgs e)
 {
     ValueChanged.Raise(this, EventArgs.Empty);
 }
コード例 #28
0
 void m_editControl_ValueChanged(object sender, EventArgs e)
 {
     ValueChanged.Raise(this, e);
 }
コード例 #29
0
ファイル: CategoryContainer.cs プロジェクト: masums/Crow
 public virtual void NotifyValueChanged(string MemberName, object _value)
 {
     ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
 }
コード例 #30
0
 private void OnBaseObservableValueChanged(object sender, object oldValue, object newValue)
 {
     Value = newValue;
     ValueChanged.Raise(this, oldValue, newValue);
 }