示例#1
0
 private EventTriggerHandler(FrameworkElement element, RoutedEvent routedEvent, IEnumerable<ITriggerAction> actions, BaseValueSource valueSource)
 {
     this.element = element;
     this.routedEvent = routedEvent;
     this.actions = actions;
     this.valueSource = valueSource;
 }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            BaseValueSource bvs = ( BaseValueSource )value;

            string uriPrefix = "/WPFToolkit.Extended;component/PropertyGrid/Images/";
            string imageName = "AdvancedProperties11";

            switch (bvs)
            {
            case BaseValueSource.Inherited:
            case BaseValueSource.DefaultStyle:
            case BaseValueSource.ImplicitStyleReference:
                imageName = "Inheritance11";
                break;

            case BaseValueSource.DefaultStyleTrigger:
                break;

            case BaseValueSource.Style:
                imageName = "Style11";
                break;

            case BaseValueSource.Local:
                imageName = "Local11";
                break;
            }


            return(new BitmapImage(new Uri(String.Format("{0}{1}.png", uriPrefix, imageName), UriKind.RelativeOrAbsolute)));
        }
示例#3
0
        // Token: 0x060048D9 RID: 18649 RVA: 0x0014AA20 File Offset: 0x00148C20
        public static object GetCoercedTransferPropertyValue(DependencyObject baseObject, object baseValue, DependencyProperty baseProperty, DependencyObject parentObject, DependencyProperty parentProperty, DependencyObject grandParentObject, DependencyProperty grandParentProperty)
        {
            object result = baseValue;

            if (DataGridHelper.IsPropertyTransferEnabled(baseObject, baseProperty))
            {
                BaseValueSource baseValueSource = DependencyPropertyHelper.GetValueSource(baseObject, baseProperty).BaseValueSource;
                if (parentObject != null)
                {
                    ValueSource valueSource = DependencyPropertyHelper.GetValueSource(parentObject, parentProperty);
                    if (valueSource.BaseValueSource > baseValueSource)
                    {
                        result          = parentObject.GetValue(parentProperty);
                        baseValueSource = valueSource.BaseValueSource;
                    }
                }
                if (grandParentObject != null)
                {
                    ValueSource valueSource2 = DependencyPropertyHelper.GetValueSource(grandParentObject, grandParentProperty);
                    if (valueSource2.BaseValueSource > baseValueSource)
                    {
                        result          = grandParentObject.GetValue(grandParentProperty);
                        baseValueSource = valueSource2.BaseValueSource;
                    }
                }
            }
            return(result);
        }
示例#4
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);

            FrameworkPropertyMetadata metadata = e.Property.GetMetadata(GetType()) as FrameworkPropertyMetadata;

            if (metadata != null)
            {
                if (metadata.AffectsMeasure)
                {
                    InvalidateMeasure();
                }

                if (metadata.AffectsArrange)
                {
                    InvalidateArrange();
                }
            }

            BaseValueSource baseValueSource = GetBaseValueSource(e.Property);

            if (baseValueSource != BaseValueSource.Default && baseValueSource != BaseValueSource.Inherited)
            {
                if (e.OldValue is IInheritableObject)
                {
                    ((IInheritableObject)e.OldValue).SetInheritanceContext(null);
                }

                if (e.NewValue is IInheritableObject)
                {
                    ((IInheritableObject)e.NewValue).SetInheritanceContext(this);
                }
            }
        }
示例#5
0
        public void Apply(FrameworkElement target, BaseValueSource valueSource)
        {
            INameScope nameScope  = valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target);
            object     layerOwner = valueSource == BaseValueSource.Local ? null : target.TemplatedParent;

            Begin(target, nameScope, layerOwner);
        }
示例#6
0
 private void Clean(FrameworkElement element, BaseValueSource valueSource)
 {
     foreach (ITriggerAction action in TriggerActions)
     {
         action.Clean(element, valueSource);
     }
 }
        internal void UpdateAdvanceOptionsForItem(MarkupObject markupObject, DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor,
                                                  out object tooltip)
        {
            tooltip = StringConstants.AdvancedProperties;

            bool isResource        = false;
            bool isDynamicResource = false;

            var markupProperty = markupObject.Properties.FirstOrDefault(p => p.Name == PropertyName);

            if (markupProperty != null)
            {
                //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style(maybe with StaticResourceExtension)
                isResource        = typeof(Style).IsAssignableFrom(markupProperty.PropertyType);
                isDynamicResource = typeof(DynamicResourceExtension).IsAssignableFrom(markupProperty.PropertyType);
            }

            if (isResource || isDynamicResource)
            {
                tooltip = StringConstants.Resource;
            }
            else
            {
                if ((dependencyObject != null) && (dpDescriptor != null))
                {
                    if (BindingOperations.GetBindingExpressionBase(dependencyObject, dpDescriptor.DependencyProperty) != null)
                    {
                        tooltip = StringConstants.Databinding;
                    }
                    else
                    {
                        BaseValueSource bvs =
                            DependencyPropertyHelper
                            .GetValueSource(dependencyObject, dpDescriptor.DependencyProperty)
                            .BaseValueSource;

                        switch (bvs)
                        {
                        case BaseValueSource.Inherited:
                        case BaseValueSource.DefaultStyle:
                        case BaseValueSource.ImplicitStyleReference:
                            tooltip = StringConstants.Inheritance;
                            break;

                        case BaseValueSource.DefaultStyleTrigger:
                            break;

                        case BaseValueSource.Style:
                            tooltip = StringConstants.StyleSetter;
                            break;

                        case BaseValueSource.Local:
                            tooltip = StringConstants.Local;
                            break;
                        }
                    }
                }
            }
        }
示例#8
0
 public ValueSource(BaseValueSource baseValueSource, bool isExpression, bool isCurrent, bool isAnimated, bool isCoerced)
 {
     this.BaseValueSource = baseValueSource;
     this.IsExpression    = isExpression;
     this.IsCurrent       = isCurrent;
     this.IsAnimated      = isAnimated;
     this.IsCoerced       = isCoerced;
 }
示例#9
0
        public override void Attach(FrameworkElement element, BaseValueSource valueSource)
        {
            IEventTriggerCondition condition = CreateEventTriggerCondition(element);

            condition.EventRaised += (sender, e) => Apply(element, valueSource);

            attachedConditions.Add(element, condition);
        }
示例#10
0
        public void Attach(FrameworkElement element, BaseValueSource valueSource)
        {
            if (Binding == null)
            {
                throw new Granular.Exception("DataTrigger.Binding cannot be null");
            }

            handlers.Add(element, new DataTriggerHandler(element, Binding, Value, Setters, valueSource));
        }
示例#11
0
        public override void Apply(FrameworkElement target, BaseValueSource valueSource)
        {
            BeginStoryboard beginStoryboard = GetBeginStoryboard(target);

            if (beginStoryboard != null)
            {
                beginStoryboard.Stop(target);
            }
        }
示例#12
0
 internal ValueSource(bool isAnimated,
                      bool isCoerced,
                      bool isExpression,
                      BaseValueSource baseValueSource)
 {
     this.isAnimated      = isAnimated;
     this.isCoerced       = isCoerced;
     this.isExpression    = isExpression;
     this.baseValueSource = baseValueSource;
 }
示例#13
0
        public void Attach(FrameworkElement element, BaseValueSource valueSource)
        {
            if (RoutedEvent == null)
            {
                throw new Granular.Exception("EventTrigger.RoutedEvent cannot be null");
            }

            FrameworkElement source = SourceName.IsNullOrEmpty() ? element : (valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(element) : NameScope.GetTemplateNameScope(element)).FindName(SourceName) as FrameworkElement;
            handlers.Add(element, EventTriggerHandler.Register(source, RoutedEvent, Actions, valueSource));
        }
示例#14
0
		internal ValueSource (bool isAnimated,
				      bool isCoerced,
				      bool isExpression,
				      BaseValueSource baseValueSource)
		{
			this.isAnimated = isAnimated;
			this.isCoerced = isCoerced;
			this.isExpression = isExpression;
			this.baseValueSource = baseValueSource;
		}
示例#15
0
        public override void Apply(FrameworkElement target, BaseValueSource valueSource)
        {
            BeginStoryboard beginStoryboard = GetBeginStoryboard(target);

            if (beginStoryboard != null)
            {
                INameScope nameScope  = valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target);
                object     layerOwner = valueSource == BaseValueSource.Local ? null : target.TemplatedParent;
                beginStoryboard.Remove(target, nameScope, layerOwner);
            }
        }
示例#16
0
 private void OnConditionIsMatchedChanged(FrameworkElement element, BaseValueSource valueSource, bool isMatched)
 {
     if (isMatched)
     {
         Apply(element, valueSource);
     }
     else
     {
         Clean(element, valueSource);
     }
 }
示例#17
0
        public InitializeContext(object target, InitializeContext parentContext, INameScope nameScope, FrameworkElement templatedParent, BaseValueSource valueSource)
        {
            this.Target = target;
            this.ParentContext = parentContext;

            this.NameScope = nameScope;
            this.TemplatedParent = templatedParent;
            this.ValueSource = valueSource;

            this.Root = parentContext != null && parentContext.Root != null ? parentContext.Root : Target;
        }
示例#18
0
        public override void Attach(FrameworkElement element, BaseValueSource valueSource)
        {
            IDataTriggerCondition condition = CreateDataTriggerCondition(element);

            condition.IsMatchedChanged += (sender, e) => OnConditionIsMatchedChanged(element, valueSource, condition.IsMatched);

            if (condition.IsMatched)
            {
                Apply(element, valueSource);
            }

            attachedConditions.Add(element, condition);
        }
示例#19
0
        public override void Detach(FrameworkElement element, BaseValueSource valueSource)
        {
            IEventTriggerCondition condition = attachedConditions[element];

            Clean(element, valueSource);

            if (condition is IDisposable)
            {
                ((IDisposable)condition).Dispose();
            }

            attachedConditions.Remove(element);
        }
示例#20
0
文件: Setter.cs 项目: diab0l/Granular
        public void ExitAction(FrameworkElement target, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Setter.Property cannot be null");
            }

            FrameworkElement resolvedTarget = GetResolvedTarget(target, TargetName, valueSource);
            DependencyProperty resolvedProperty = Property.GetDependencyProperty(resolvedTarget.GetType());
            BaseValueSource resolvedValueSource = GetResolvedValueSource(valueSource, resolvedTarget);

            resolvedTarget.ClearValue(resolvedProperty, resolvedValueSource);
        }
示例#21
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);

            FrameworkPropertyMetadata metadata = e.Property.GetMetadata(GetType()) as FrameworkPropertyMetadata;

            if (metadata != null)
            {
                if (metadata.AffectsMeasure)
                {
                    InvalidateMeasure();
                }

                if (metadata.AffectsArrange)
                {
                    InvalidateArrange();
                }

                if (metadata.AffectsRender)
                {
                    InvalidateVisual();
                }

                if (metadata.AffectsParentMeasure && VisualParent != null)
                {
                    ((UIElement)VisualParent).InvalidateMeasure();
                }

                if (metadata.AffectsParentArrange && VisualParent != null)
                {
                    ((UIElement)VisualParent).InvalidateArrange();
                }
            }

            if (!e.IsSubPropertyChange)
            {
                BaseValueSource baseValueSource = GetBaseValueSource(e.Property);
                if (baseValueSource != BaseValueSource.Default && baseValueSource != BaseValueSource.Inherited)
                {
                    if (e.OldValue is IContextElement)
                    {
                        ((IContextElement)e.OldValue).TrySetContextParent(null);
                    }

                    if (e.NewValue is IContextElement)
                    {
                        ((IContextElement)e.NewValue).TrySetContextParent(this);
                    }
                }
            }
        }
示例#22
0
        public void Attach(FrameworkElement element, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Trigger.Property cannot be null");
            }

            DependencyProperty dependencyProperty = Property.GetDependencyProperty(element.GetType());

            object resolvedValue = Value == null || dependencyProperty.PropertyType.IsInstanceOfType(Value) ? Value : TypeConverter.ConvertValue(Value.ToString(), dependencyProperty.PropertyType, XamlNamespaces.Empty);

            FrameworkElement source = SourceName.IsNullOrEmpty() ? element : NameScope.GetTemplateNameScope(element).FindName(SourceName) as FrameworkElement;
            handlers.Add(element, TriggerHandler.Register(source, dependencyProperty, resolvedValue, Setters, valueSource));
        }
示例#23
0
文件: Setter.cs 项目: diab0l/Granular
        public void EnterAction(FrameworkElement target, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Setter.Property cannot be null");
            }

            FrameworkElement resolvedTarget = GetResolvedTarget(target, TargetName, valueSource);
            DependencyProperty resolvedProperty = Property.GetDependencyProperty(resolvedTarget.GetType());
            object resolvedValue = Value == null || Value is IExpressionProvider || resolvedProperty.PropertyType.IsInstanceOfType(Value) ? Value : TypeConverter.ConvertValue(Value.ToString(), resolvedProperty.PropertyType, XamlNamespaces.Empty);
            BaseValueSource resolvedValueSource = GetResolvedValueSource(valueSource, resolvedTarget);

            resolvedTarget.SetValue(resolvedProperty, resolvedValue, resolvedValueSource);
        }
示例#24
0
        internal static Collection <VisualStateGroup> GetVisualStateGroupsInternal(FrameworkElement obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            // We don't want to get the default value because it will create/return an empty colleciton.
            BaseValueSource source = DependencyPropertyHelper.GetValueSource(obj, VisualStateGroupsProperty).BaseValueSource;

            if (source != BaseValueSource.Default)
            {
                return(obj.GetValue(VisualStateManager.VisualStateGroupsProperty) as Collection <VisualStateGroup>);
            }

            return(null);
        }
        private static object CoerceCursor(DependencyObject o, object value)
        {
            GridSplitter    splitter  = (GridSplitter)o;
            BaseValueSource internal2 = DependencyPropertyHelper.GetValueSource(splitter, FrameworkElement.CursorProperty).BaseValueSource;

            if ((value == null) && (internal2 == BaseValueSource.Default))
            {
                switch (splitter.GetEffectiveResizeDirection())
                {
                case GridResizeDirection.Columns:
                    return(Cursors.SizeWE);

                case GridResizeDirection.Rows:
                    return(Cursors.SizeNS);
                }
            }
            return(value);
        }
示例#26
0
        public ValueSource GetValueSource(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry;

            if (entries.TryGetValue(dependencyProperty, out entry))
            {
                return(new ValueSource(
                           (BaseValueSource)entry.GetBaseValuePriority(),
                           entry.GetBaseValue(false) is IExpression || entry.GetCurrentValue(false) is IExpression,
                           entry.GetCurrentValue(true) != ObservableValue.UnsetValue,
                           entry.GetAnimationValue(true) != ObservableValue.UnsetValue,
                           (entry is CoercedDependencyPropertyValueEntry) && ((CoercedDependencyPropertyValueEntry)entry).IsCoerced));
            }

            PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType());
            BaseValueSource  baseValueSource  = propertyMetadata.Inherits && inheritanceParent != null ? BaseValueSource.Inherited : BaseValueSource.Default;

            return(new ValueSource(baseValueSource, false, false, false, false));
        }
示例#27
0
        public void Clean(FrameworkElement target, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Setter.Property cannot be null");
            }

            FrameworkElement   resolvedTarget      = GetResolvedTarget(target, TargetName, valueSource);
            DependencyProperty resolvedProperty    = Property.GetDependencyProperty(resolvedTarget.GetType());
            BaseValueSource    resolvedValueSource = GetResolvedValueSource(valueSource, resolvedTarget);

            if (IsStyleValueSource(valueSource))
            {
                resolvedTarget.ClearValue(resolvedProperty, resolvedValueSource);
            }
            else
            {
                GetInitializedValueOverlapExpression(resolvedTarget, resolvedProperty, resolvedValueSource).ClearValue(this);
            }
        }
示例#28
0
        public void Clean(FrameworkElement target, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Setter.Property cannot be null");
            }

            FrameworkElement resolvedTarget = GetResolvedTarget(target, TargetName, valueSource);
            DependencyProperty resolvedProperty = Property.GetDependencyProperty(resolvedTarget.GetType());
            BaseValueSource resolvedValueSource = GetResolvedValueSource(valueSource, resolvedTarget);

            if (IsStyleValueSource(valueSource))
            {
                resolvedTarget.ClearValue(resolvedProperty, resolvedValueSource);
            }
            else
            {
                GetInitializedValueOverlapExpression(resolvedTarget, resolvedProperty, resolvedValueSource).ClearValue(this);
            }
        }
示例#29
0
        public void Apply(FrameworkElement target, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Setter.Property cannot be null");
            }

            FrameworkElement   resolvedTarget      = GetResolvedTarget(target, TargetName, valueSource);
            DependencyProperty resolvedProperty    = Property.GetDependencyProperty(resolvedTarget.GetType());
            object             resolvedValue       = Value == null || Value is IExpressionProvider || resolvedProperty.PropertyType.IsInstanceOfType(Value) ? Value : TypeConverter.ConvertValue(Value.ToString(), resolvedProperty.PropertyType, XamlNamespaces.Empty);
            BaseValueSource    resolvedValueSource = GetResolvedValueSource(valueSource, resolvedTarget);

            if (IsStyleValueSource(valueSource)) // no need to use value overlap expression in style setters
            {
                resolvedTarget.SetValue(resolvedProperty, resolvedValue, resolvedValueSource);
            }
            else
            {
                GetInitializedValueOverlapExpression(resolvedTarget, resolvedProperty, resolvedValueSource).SetValue(this, resolvedValue);
            }
        }
示例#30
0
        internal static bool SetIfNonLocal <T>(this DependencyObject o, DependencyProperty property, T value)
        {
            Contract.Requires(o != null);
            Contract.Requires(property != null);

            if (!property.PropertyType.IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("Type of dependency property is incompatible with value.");
            }

            BaseValueSource source = DependencyPropertyHelper.GetValueSource(o, property).BaseValueSource;

            if (source != BaseValueSource.Local)
            {
                o.SetValue(property, value);

                return(true);
            }

            return(false);
        }
示例#31
0
        public void Apply(FrameworkElement target, BaseValueSource valueSource)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Setter.Property cannot be null");
            }

            FrameworkElement resolvedTarget = GetResolvedTarget(target, TargetName, valueSource);
            DependencyProperty resolvedProperty = Property.GetDependencyProperty(resolvedTarget.GetType());
            object resolvedValue = Value == null || Value is IExpressionProvider || resolvedProperty.PropertyType.IsInstanceOfType(Value) ? Value : TypeConverter.ConvertValue(Value.ToString(), resolvedProperty.PropertyType, XamlNamespaces.Empty);
            BaseValueSource resolvedValueSource = GetResolvedValueSource(valueSource, resolvedTarget);

            if (IsStyleValueSource(valueSource)) // no need to use value overlap expression in style setters
            {
                resolvedTarget.SetValue(resolvedProperty, resolvedValue, resolvedValueSource);
            }
            else
            {
                GetInitializedValueOverlapExpression(resolvedTarget, resolvedProperty, resolvedValueSource).SetValue(this, resolvedValue);
            }
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            BaseValueSource bvs     = ( BaseValueSource )value;
            string          toolTip = "Advanced Properties";

            switch (bvs)
            {
            case BaseValueSource.Inherited:
            case BaseValueSource.DefaultStyle:
            case BaseValueSource.ImplicitStyleReference:
                toolTip = "Inheritance";
                break;

            case BaseValueSource.Style:
                toolTip = "Style Setter";
                break;

            case BaseValueSource.Local:
                toolTip = "Local";
                break;
            }

            return(toolTip);
        }
        internal void UpdateAdvanceOptionsForItem(MarkupObject markupObject, DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor,
                                                  out string imageName, out object tooltip)
        {
            imageName = "AdvancedProperties11";
            tooltip   = "Advanced Properties";

            bool isResource        = false;
            bool isDynamicResource = false;

            var markupProperty = markupObject.Properties.Where(p => p.Name == PropertyName).FirstOrDefault();

            if (markupProperty != null)
            {
                //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style
                isResource        = (markupProperty.Value is Style);
                isDynamicResource = (markupProperty.Value is DynamicResourceExtension);
            }

            if (isResource || isDynamicResource)
            {
                imageName = "Resource11";
                tooltip   = "Resource";
            }
            else
            {
                if ((dependencyObject != null) && (dpDescriptor != null))
                {
                    if (BindingOperations.GetBindingExpressionBase(dependencyObject, dpDescriptor.DependencyProperty) != null)
                    {
                        imageName = "Database11";
                        tooltip   = "Databinding";
                    }
                    else
                    {
                        BaseValueSource bvs =
                            DependencyPropertyHelper
                            .GetValueSource(dependencyObject, dpDescriptor.DependencyProperty)
                            .BaseValueSource;

                        switch (bvs)
                        {
                        case BaseValueSource.Inherited:
                        case BaseValueSource.DefaultStyle:
                        case BaseValueSource.ImplicitStyleReference:
                            imageName = "Inheritance11";
                            tooltip   = "Inheritance";
                            break;

                        case BaseValueSource.DefaultStyleTrigger:
                            break;

                        case BaseValueSource.Style:
                            imageName = "Style11";
                            tooltip   = "Style Setter";
                            break;

                        case BaseValueSource.Local:
                            imageName = "Local11";
                            tooltip   = "Local";
                            break;
                        }
                    }
                }
            }
        }
示例#34
0
        private static ValueOverlapExpression GetInitializedValueOverlapExpression(FrameworkElement target, DependencyProperty property, BaseValueSource valueSource)
        {
            ValueOverlapExpression valueOverlapExpression = target.GetValueEntry(property).GetBaseValue((int)valueSource, false) as ValueOverlapExpression;

            if (valueOverlapExpression == null)
            {
                valueOverlapExpression = new ValueOverlapExpression();
                target.SetValue(property, valueOverlapExpression, valueSource);
            }

            return valueOverlapExpression;
        }
示例#35
0
 public abstract void EnterAction(FrameworkElement target, BaseValueSource valueSource);
示例#36
0
 private static void AssertValueSource(ValueSource valueSource, bool isCurrent = false, bool isExpression = false, BaseValueSource baseValueSource = BaseValueSource.Local)
 {
     Assert.AreEqual(isCurrent, valueSource.IsCurrent);
     Assert.AreEqual(isExpression, valueSource.IsExpression);
     Assert.AreEqual(baseValueSource, valueSource.BaseValueSource);
 }
示例#37
0
 public void ClearValue(DependencyPropertyKey dependencyPropertyKey, BaseValueSource source = BaseValueSource.Local)
 {
     ClearValue(dependencyPropertyKey.DependencyProperty, dependencyPropertyKey, source);
 }
示例#38
0
 public void Apply(FrameworkElement target, BaseValueSource valueSource)
 {
     ApplyCount++;
 }
示例#39
0
 public static IDisposable Register(FrameworkElement element, RoutedEvent routedEvent, IEnumerable<ITriggerAction> actions, BaseValueSource valueSource)
 {
     EventTriggerHandler handler = new EventTriggerHandler(element, routedEvent, actions, valueSource);
     handler.Register();
     return handler;
 }
示例#40
0
 public void SetValue(object target, object value, BaseValueSource valueSource)
 {
     property.SetValue(target, value, index);
 }
 private static void AssertValueSource(ValueSource valueSource, bool isCurrent = false, bool isExpression = false, BaseValueSource baseValueSource = BaseValueSource.Local)
 {
     Assert.AreEqual(isCurrent, valueSource.IsCurrent);
     Assert.AreEqual(isExpression, valueSource.IsExpression);
     Assert.AreEqual(baseValueSource, valueSource.BaseValueSource);
 }
示例#42
0
 public void SetValue(DependencyPropertyKey dependencyPropertyKey, object value, BaseValueSource source = BaseValueSource.Local)
 {
     SetValue(dependencyPropertyKey.DependencyProperty, dependencyPropertyKey, value, source: source);
 }
示例#43
0
 public void ExitAction(FrameworkElement target, BaseValueSource valueSource)
 {
     target.RemoveHandler(Event, Handler);
 }
示例#44
0
 public void EnterAction(FrameworkElement target, BaseValueSource valueSource)
 {
     target.AddHandler(Event, Handler, HandledEventsToo);
 }
示例#45
0
 public void SetValue(object target, object value, BaseValueSource valueSource)
 {
     ((DependencyObject)target).SetValue(property, value, valueSource);
 }
示例#46
0
        public override void EnterAction(FrameworkElement target, BaseValueSource valueSource)
        {
            BeginStoryboard beginStoryboard = GetBeginStoryboard(target);

            if (beginStoryboard != null)
            {
                beginStoryboard.Stop(target);
            }
        }
示例#47
0
 public void SetValue(object target, object value, BaseValueSource valueSource)
 {
     property.SetValue(target, value, index);
 }
示例#48
0
 public ValueSource(BaseValueSource baseValueSource, bool isExpression, bool isCurrent, bool isAnimated, bool isCoerced)
 {
     this.BaseValueSource = baseValueSource;
     this.IsExpression = isExpression;
     this.IsCurrent = isCurrent;
     this.IsAnimated = isAnimated;
     this.IsCoerced = isCoerced;
 }
示例#49
0
 public void Clean(FrameworkElement target, BaseValueSource valueSource)
 {
     ClearCount++;
 }
示例#50
0
 private static bool IsStyleValueSource(BaseValueSource valueSource)
 {
     return valueSource == BaseValueSource.ThemeStyle || valueSource == BaseValueSource.Style;
 }
示例#51
0
        public override void EnterAction(FrameworkElement target, BaseValueSource valueSource)
        {
            BeginStoryboard beginStoryboard = GetBeginStoryboard(target);

            if (beginStoryboard != null)
            {
                INameScope nameScope = valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target);
                object layerOwner = valueSource == BaseValueSource.Local ? null : target.TemplatedParent;
                beginStoryboard.Remove(target, nameScope, layerOwner);
            }
        }
示例#52
0
        private void ClearValue(DependencyProperty dependencyProperty, DependencyPropertyKey dependencyPropertyKey, BaseValueSource source)
        {
            VerifyReadOnlyProperty(dependencyProperty, dependencyPropertyKey);

            IDependencyPropertyValueEntry entry;
            if (!entries.TryGetValue(dependencyProperty, out entry))
            {
                return;
            }

            IExpression expression = entry.GetBaseValue((int)source, false) as IExpression;
            if (expression is IDisposable)
            {
                ((IDisposable)expression).Dispose();
            }

            entry.ClearBaseValue((int)source);
            entry.ClearCurrentValue();
        }
示例#53
0
 public void SetValue(object target, object value, BaseValueSource valueSource)
 {
     ((DependencyObject)target).SetValue(property, value, valueSource);
 }
示例#54
0
 private static FrameworkElement GetResolvedTarget(FrameworkElement target, string targetName, BaseValueSource valueSource)
 {
     return targetName.IsNullOrEmpty() ? target : (valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target)).FindName(targetName) as FrameworkElement;
 }
示例#55
0
 public abstract void Detach(FrameworkElement element, BaseValueSource valueSource);
示例#56
0
 private static BaseValueSource GetResolvedValueSource(BaseValueSource valueSource, FrameworkElement target)
 {
     return valueSource == BaseValueSource.TemplateTrigger && target.TemplatedParent != null ? BaseValueSource.ParentTemplateTrigger : valueSource;
 }
示例#57
0
 public void EnterAction(FrameworkElement target, BaseValueSource valueSource)
 {
     INameScope nameScope = valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target);
     object layerOwner = valueSource == BaseValueSource.Local ? null : target.TemplatedParent;
     Begin(target, nameScope, layerOwner);
 }
示例#58
0
        private void SetValue(DependencyProperty dependencyProperty, DependencyPropertyKey dependencyPropertyKey, object value, bool setCurrentValue = false, BaseValueSource source = BaseValueSource.Unknown)
        {
            VerifyReadOnlyProperty(dependencyProperty, dependencyPropertyKey);

            IExpressionProvider newExpressionProvider = value as IExpressionProvider;
            if (newExpressionProvider == null && !dependencyProperty.IsValidValue(value))
            {
                return; // invalid value
            }

            IDependencyPropertyValueEntry entry = GetInitializedValueEntry(dependencyProperty);

            IExpression oldExpression = setCurrentValue ?
                entry.GetBaseValue(false) as IExpression : // current value may be set in the top priority expression
                entry.GetBaseValue((int)source, false) as IExpression;

            if (newExpressionProvider != null)
            {
                value = newExpressionProvider.CreateExpression(this, dependencyProperty);
            }
            else if (oldExpression != null && oldExpression.SetValue(value))
            {
                return; // value (current or not) was set in the existing expression, nothing else to do
            }

            if (setCurrentValue)
            {
                entry.SetCurrentValue(value);
                return; // base value isn't changed
            }

            if (oldExpression is IDisposable) // expression is being replaced
            {
                ((IDisposable)oldExpression).Dispose();
            }

            entry.SetBaseValue((int)source, value);
            entry.ClearCurrentValue();
        }
示例#59
0
        internal void UpdateAdvanceOptionsForItem(DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor, out object tooltip)
        {
            tooltip = StringConstants.Default;

            bool isResource        = false;
            bool isDynamicResource = false;

            //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style(maybe with StaticResourceExtension)
            isResource        = typeof(Style).IsAssignableFrom(this.PropertyType);
            isDynamicResource = typeof(DynamicResourceExtension).IsAssignableFrom(this.PropertyType);

            if (isResource || isDynamicResource)
            {
                tooltip = StringConstants.Resource;
            }
            else
            {
                if ((dependencyObject != null) && (dpDescriptor != null))
                {
                    if (BindingOperations.GetBindingExpressionBase(dependencyObject, dpDescriptor.DependencyProperty) != null)
                    {
                        tooltip = StringConstants.Databinding;
                    }
                    else
                    {
                        BaseValueSource bvs =
                            DependencyPropertyHelper
                            .GetValueSource(dependencyObject, dpDescriptor.DependencyProperty)
                            .BaseValueSource;

                        switch (bvs)
                        {
                        case BaseValueSource.Inherited:
                        case BaseValueSource.DefaultStyle:
                        case BaseValueSource.ImplicitStyleReference:
                            tooltip = StringConstants.Inheritance;
                            break;

                        case BaseValueSource.DefaultStyleTrigger:
                            break;

                        case BaseValueSource.Style:
                            tooltip = StringConstants.StyleSetter;
                            break;

                        case BaseValueSource.Local:
                            tooltip = StringConstants.Local;
                            break;
                        }
                    }
                }
                else
                {
                    // When the Value is diferent from the DefaultValue, use the local icon.
                    if (!object.Equals(this.Value, this.DefaultValue))
                    {
                        if (this.DefaultValue != null)
                        {
                            tooltip = StringConstants.Local;
                        }
                        else
                        {
                            if (this.PropertyType.IsValueType)
                            {
                                var defaultValue = Activator.CreateInstance(this.PropertyType);
                                // When the Value is diferent from the DefaultValue, use the local icon.
                                if (!object.Equals(this.Value, defaultValue))
                                {
                                    tooltip = StringConstants.Local;
                                }
                            }
                            else
                            {
                                // When the Value is diferent from null, use the local icon.
                                if (this.Value != null)
                                {
                                    tooltip = StringConstants.Local;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#60
0
 public void ExitAction(FrameworkElement target, BaseValueSource valueSource)
 {
     //
 }