Esempio n. 1
0
        public override bool Evaluate(RadObject target)
        {
            if (target == null)
            {
                return(false);
            }
            switch (this.BinaryOperator)
            {
            case BinaryOperator.AndOperator:
                if (this.Condition1.Evaluate(target))
                {
                    return(this.Condition2.Evaluate(target));
                }
                return(false);

            case BinaryOperator.OrOperator:
                if (!this.Condition1.Evaluate(target))
                {
                    return(this.Condition2.Evaluate(target));
                }
                return(true);

            case BinaryOperator.XorOperator:
                return(this.Condition1.Evaluate(target) != this.Condition2.Evaluate(target));

            default:
                return(false);
            }
        }
Esempio n. 2
0
        public override LinkedList <RadObject> GetSelectedElements(RadObject element)
        {
            IStylableNode stylableNode = element as IStylableNode;

            if (stylableNode == null)
            {
                return(new LinkedList <RadObject>());
            }
            if (this.childrenHierarchyByElement != null && this.CanUseCache)
            {
                return(this.FindElements(this.childrenHierarchyByElement) ?? new LinkedList <RadObject>());
            }
            LinkedList <RadObject> linkedList = new LinkedList <RadObject>();

            if (this.CanSelectOverride(element))
            {
                linkedList.AddLast(element);
            }
            if (this.CanSelectOverride(element))
            {
                linkedList.AddLast(element);
            }
            foreach (RadObject targetElement in stylableNode.ChildrenHierarchy)
            {
                if (this.CanSelectIgnoringConditions(targetElement))
                {
                    linkedList.AddLast(targetElement);
                }
            }
            return(linkedList);
        }
Esempio n. 3
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;
 }
Esempio n. 4
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);
        }
Esempio n. 5
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;
 }
        private bool IsAnimationEnabled(RadObject element)
        {
            bool       flag       = ThemeResolutionService.AllowAnimations && AnimatedPropertySetting.AnimationsEnabled;
            RadElement radElement = element as RadElement;

            if (radElement != null && flag)
            {
                ComponentThemableElementTree elementTree = radElement.ElementTree;
                if (elementTree == null || !elementTree.AnimationsEnabled || radElement.Visibility != ElementVisibility.Visible)
                {
                    return(false);
                }
                Control control = elementTree.Control;
                if (control == null)
                {
                    return(false);
                }
                flag = control.Visible;
                RadControl radControl = control as RadControl;
                if (radControl != null && !radControl.Visible && !radControl.IsLoaded)
                {
                    flag = true;
                }
            }
            return(flag);
        }
Esempio n. 7
0
        private int FindBoundObjectIndex(RadObject boundObject)
        {
            if (this.boundObjects == null)
            {
                return(-1);
            }

            int count = this.boundObjects.Count;

            for (int i = count - 1; i >= 0; i--)
            {
                PropertyBoundObject relation = this.boundObjects[i];
                RadObject           obj      = relation.Object;
                if (obj == null)
                {
                    this.boundObjects.RemoveAt(i);
                }
                else if (obj == boundObject)
                {
                    return(i);
                }
            }

            return(-1);
        }
Esempio n. 8
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);
        }
 public void ApplyValue(RadObject element)
 {
     this.RemovePreviousAnimation(element);
     if (!this.IsAnimationEnabled(element))
     {
         this.OnAnimationStarted(new AnimationStatusEventArgs(element, false));
         this.OnAnimationFinished(new AnimationStatusEventArgs(element, true, !this.RemoveAfterApply));
     }
     else
     {
         ElementValuesAnimator animator = this.GetAnimator(element);
         animator.Initialize(element, this.startValue != null ? this.startValue : element.GetValue(this.Property));
         if (this.RandomDelay != 0)
         {
             this.ApplyDelay = AnimatedPropertySetting.rand.Next(this.RandomDelay);
         }
         if (this.ApplyDelay > 0)
         {
             animator.Waiting = true;
             Timer timer = new Timer();
             timer.Interval = this.ApplyDelay;
             timer.Tick    += new EventHandler(this.delayTimer_Tick);
             timer.Tag      = (object)element;
             timer.Start();
         }
         else
         {
             this.OnAnimationStarted(new AnimationStatusEventArgs(element, false));
             animator.Start(element);
         }
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Gets notified that the specified object has unbound itself from a property of ours.
        /// </summary>
        /// <param name="boundObject"></param>
        /// <param name="binding"></param>
        internal void OnPropertyUnboundExternally(PropertyBinding binding, RadObject boundObject)
        {
            if (this.IsDisposing)
            {
                return;
            }

            RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, false);

            if (propVal == null)
            {
                return;
            }

            propVal.BeginUpdate(true, false);

            //remove previously registered relations
            propVal.RemoveBoundObject(boundObject);

            if ((binding.BindingOptions & PropertyBindingOptions.TwoWay) == PropertyBindingOptions.TwoWay)
            {
                //reset the local value applied from the two-way binding
                this.ResetValueCore(propVal, ValueResetFlags.TwoWayBindingLocal);
            }

            if ((binding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue)
            {
                propVal.SetLocalValue(binding.GetValue());
            }

            propVal.EndUpdate(true, false);
            this.UpdateValueCore(propVal);
        }
Esempio n. 11
0
        /// <summary>
        /// Gets notified that the specified object has bound to a property of ours.
        /// </summary>
        /// <param name="boundObject">The instance that has bound the specified property.</param>
        /// <param name="binding"></param>
        internal void OnPropertyBoundExternally(PropertyBinding binding, RadObject boundObject)
        {
            RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, true);

            //register the bound object and its property
            propVal.AddBoundObject(new PropertyBoundObject(boundObject, binding.BoundProperty));
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        internal void OnPropertyUnboundExternally(PropertyBinding binding, RadObject boundObject)
        {
            if (this.IsDisposing)
            {
                return;
            }
            RadPropertyValue entry = this.propertyValues.GetEntry(binding.SourceProperty, false);

            if (entry == null)
            {
                return;
            }
            entry.BeginUpdate(true, false);
            entry.RemoveBoundObject(boundObject);
            if ((binding.BindingOptions & PropertyBindingOptions.TwoWay) == PropertyBindingOptions.TwoWay)
            {
                int num1 = (int)this.ResetValueCore(entry, ValueResetFlags.TwoWayBindingLocal);
            }
            if ((binding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue)
            {
                entry.SetLocalValue(binding.GetValue());
            }
            entry.EndUpdate(true, false);
            int num2 = (int)this.UpdateValueCore(entry);
        }
Esempio 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);
        }
Esempio n. 15
0
        /// <summary>
        /// Notifies all bound objects for a change in this property.
        /// </summary>
        internal void NotifyBoundObjects()
        {
            //no bound objects registered
            if (this.boundObjects == null)
            {
                return;
            }

            //update all bound objects that our value has changed
            int count = this.boundObjects.Count;

            for (int i = count - 1; i >= 0; i--)
            {
                PropertyBoundObject relation = this.boundObjects[i];
                RadObject           obj      = relation.Object;
                if (obj != null)
                {
                    obj.OnBoundSourcePropertyChanged(relation.Property);
                }
                else
                {
                    this.boundObjects.RemoveAt(i);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Resets all references - such as binding references and property modifiers.
        /// </summary>
        internal void Dispose()
        {
            this.lockComposeCount++;
            this.lockValueUpdateCount++;
            //remove binding references
            this.owner.RemoveBinding(this);

            if (this.boundObjects != null)
            {
                int count = this.boundObjects.Count;
                for (int i = count - 1; i >= 0; i--)
                {
                    PropertyBoundObject reference   = this.boundObjects[i];
                    RadObject           boundObject = reference.Object;
                    if (boundObject != null &&
                        !(boundObject.IsDisposed || boundObject.IsDisposing))
                    {
                        boundObject.UnbindProperty(reference.Property);
                    }
                }
                this.boundObjects.Clear();
            }

            //reset references
            this.property         = null;
            this.metadata         = null;
            this.owner            = null;
            this.propertyBinding  = null;
            this.animationSetting = null;
            this.styleSetting     = null;
        }
Esempio n. 17
0
        public void Apply(RadObject radObject, bool initializing)
        {
            IStylableElement stylable = radObject as IStylableElement;

            if (stylable != null)
            {
                if (!this.ApplySimpleSettings(stylable))
                {
                    this.ApplyVisualStateSettings(stylable, initializing);
                }
            }
            else
            {
                IStylableNode stylableNode = radObject as IStylableNode;
                if (stylableNode != null)
                {
                    foreach (PropertySettingGroup setting in this.settings)
                    {
                        if (setting.Selector == null || setting.Selector.IsCompatible(radObject))
                        {
                            stylableNode.ApplySettings(setting);
                        }
                    }
                }
            }
            if (!(radObject is RadItem))
            {
                return;
            }
            ((RadItem)radObject).ApplyThemeSettingsOverride();
        }
Esempio n. 18
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;
 }
Esempio n. 19
0
        public void ApplyThemeToElement(RadObject element, bool recursive)
        {
            if (this.ComponentTreeHandler.Initializing)
            {
                return;
            }
            this.EnsureTheme();
            if (this.theme == null)
            {
                return;
            }
            StyleGroup styleGroup = this.theme.FindStyleGroup(this.Control);

            if (styleGroup == null)
            {
                for (IStylableNode stylableNode = element as IStylableNode; styleGroup == null && stylableNode != null; stylableNode = stylableNode.Parent)
                {
                    IStylableElement stylableElement = stylableNode as IStylableElement;
                    if (stylableElement != null)
                    {
                        styleGroup = this.theme.FindStyleGroup((IStylableNode)stylableElement);
                    }
                }
            }
            this.SuspendAnimations();
            this.ApplyStyleCore(element, styleGroup, (RadObject)this.RootElement, recursive);
            this.ResumeAnimations();
            if (element != this.RootElement)
            {
                return;
            }
            this.RootElement.IsThemeApplied = true;
        }
Esempio n. 20
0
 public void Resume(RadObject element)
 {
     if (this.IsRunning)
     {
         return;
     }
     this.animationTimer.Start();
 }
Esempio n. 21
0
 public void Pause(RadObject element)
 {
     if (!this.IsRunning)
     {
         return;
     }
     this.animationTimer.Stop();
 }
Esempio n. 22
0
 public AnimationStatusEventArgs(
     RadObject element,
     bool isAnimationInterrupt,
     bool registerValueAsLocal)
     : this(element, isAnimationInterrupt)
 {
     this.registerValueAsLocal = registerValueAsLocal;
 }
Esempio n. 23
0
 public virtual bool CanSelect(RadObject targetElement)
 {
     if (this.CanSelectOverride(targetElement))
     {
         return(this.CanSelectCore(targetElement));
     }
     return(false);
 }
Esempio n. 24
0
 public RadPropertyMetadata GetMetadata(RadObject radObject)
 {
     if (radObject == null)
     {
         throw new ArgumentNullException(nameof(radObject));
     }
     return(this.GetMetadata(radObject.RadObjectType));
 }
Esempio n. 25
0
        public void UpdateValue()
        {
            RadObject obj = this.Object;

            if (obj != null)
            {
                obj.UpdateValue(this.boundProperty);
            }
        }
Esempio n. 26
0
        protected override void PropertySettingRemoving(RadObject targetRadObject)
        {
            ElementValuesAnimator animator = ((RadElement)targetRadObject).ValuesAnimators[this.GetHashCode()] as ElementValuesAnimator;

            if (animator != null)
            {
                animator.SettingRemoving();
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Removes previously registered bound object.
        /// </summary>
        /// <param name="boundObject"></param>
        internal void RemoveBoundObject(RadObject boundObject)
        {
            int index = this.FindBoundObjectIndex(boundObject);

            if (index != -1)
            {
                this.boundObjects.RemoveAt(index);
            }
        }
        public bool IsAnimating(RadObject element)
        {
            ElementValuesAnimator valuesAnimator = element.ValuesAnimators[(object)this.GetHashCode()] as ElementValuesAnimator;

            if (valuesAnimator != null)
            {
                return(valuesAnimator.IsRunning);
            }
            return(false);
        }
Esempio n. 29
0
        protected override bool CanSelectOverride(RadObject element)
        {
            IStylableNode stylableNode = element as IStylableNode;

            if (stylableNode != null && element != null)
            {
                return(string.Compare(stylableNode.Class, this.elementClass, true) == 0);
            }
            return(false);
        }
Esempio n. 30
0
 public void Start(RadObject element)
 {
     if (this.running)
     {
         return;
     }
     this.running      = true;
     this.currentFrame = 0;
     this.StartTimer();
 }