Example #1
0
        public virtual void Unapply(RadElement radElement)
        {
            if (cachedChildrenHierarchyByElement.Count == 0)
            {
                PrepareCache(radElement);
            }

            for (int i = 0; i < this.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = this.PropertySettingGroups[i];
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector selector = group.Selectors[k];
                    if (selector is HierarchicalSelector)
                    {
                        ((HierarchicalSelector)selector).SetCache(this.cachedChildrenHierarchyByElement);
                    }

                    LinkedList <RadElement> selectedElements = selector.GetSelectedElements(radElement);
                    foreach (RadElement selected in selectedElements)
                    {
                        selector.Unregister(selected, group.PropertySettings);
                    }
                }
            }

            for (int i = 0; i < this.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = this.PropertySettingGroups[i];
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector        selector         = group.Selectors[k];
                    LinkedList <RadElement> selectedElements = selector.GetSelectedElements(radElement);
                    foreach (RadElement selected in selectedElements)
                    {
                        PropertyChangeBehaviorCollection propertyChangeBehaviors = selector.GetBehaviors(group);
                        for (int behaviorIndex = 0; behaviorIndex < propertyChangeBehaviors.Count; behaviorIndex++)
                        {
                            PropertyChangeBehavior toRemove = propertyChangeBehaviors[behaviorIndex];
                            toRemove.BehaviorRemoving(selected);
                        }

                        RoutedEventBehaviorCollection routedEventBehaviors = selector.GetRoutedEventBehaviors(group);
                        for (int eventIndex = 0; eventIndex < routedEventBehaviors.Count; eventIndex++)
                        {
                            RoutedEventBehavior routedEventBehavior = routedEventBehaviors[eventIndex];
                            routedEventBehavior.BehaviorRemoving(selected);
                        }

                        selected.RemoveRangeBehaviors(propertyChangeBehaviors);
                        selected.RemoveRangeRoutedEventBehaviors(routedEventBehaviors);
                    }
                }
            }

            this.cachedChildrenHierarchyByElement.Clear();
        }
Example #2
0
 public virtual PropertyChangeBehaviorCollection GetBehaviors(
     PropertySettingGroup group)
 {
     if (this.createdPropertyChangeBehaviors == null)
     {
         if (this.condition != null)
         {
             throw new NotImplementedException();
         }
         this.createdPropertyChangeBehaviors = new PropertyChangeBehaviorCollection();
     }
     return(this.createdPropertyChangeBehaviors);
 }
Example #3
0
        //Method supports old theming infrastructure and will be depricated
        public virtual PropertyChangeBehaviorCollection GetBehaviors(PropertySettingGroup group)
        {
            if (this.createdPropertyChangeBehaviors == null)
            {
                if (this.condition != null)
                {
                    this.createdPropertyChangeBehaviors = new PropertyChangeBehaviorCollection(condition.AffectedProperties.Count);
                    for (int i = 0; i < condition.AffectedProperties.Count; i++)
                    {
                        RadProperty property = condition.AffectedProperties[i];
                        PropertyChangeStyleBehavior behavior =
                            new PropertyChangeStyleBehavior(property, this, group.PropertySettings);

                        this.createdPropertyChangeBehaviors.Add(behavior);
                    }
                }
                else
                {
                    this.createdPropertyChangeBehaviors = new PropertyChangeBehaviorCollection();
                }
            }

            return(createdPropertyChangeBehaviors);
        }