示例#1
0
        // This will transfer information in the _setters collection to PropertyValues array.
        internal void ProcessSettersCollection(SetterBaseCollection setters)
        {
            // Add information in Setters collection to PropertyValues array.
            if (setters != null)
            {
                // Seal Setters
                setters.Seal();

                for (int i = 0; i < setters.Count; i++)
                {
                    Setter setter = setters[i] as Setter;
                    if (setter != null)
                    {
                        DependencyProperty dp     = setter.Property;
                        object             value  = setter.ValueInternal;
                        string             target = setter.TargetName;

                        if (target == null)
                        {
                            ProcessParametersContainer(dp);

                            target = StyleHelper.SelfName;
                        }
                        else
                        {
                            target = ProcessParametersVisualTreeChild(dp, target); // name string will get interned
                        }

                        DynamicResourceExtension dynamicResource = value as DynamicResourceExtension;
                        if (dynamicResource == null)
                        {
                            AddToPropertyValues(target, dp, value, PropertyValueType.Trigger);
                        }
                        else
                        {
                            AddToPropertyValues(target, dp, dynamicResource.ResourceKey, PropertyValueType.PropertyTriggerResource);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException(SR.Get(SRID.VisualTriggerSettersIncludeUnsupportedSetterType, setters[i].GetType().Name));
                    }
                }
            }
        }
示例#2
0
    void IAddChild.AddChild(object child)
    {
      if (child == null)
      {
        throw new ArgumentNullException("child");
      }

      if (child is SetterBase == false)
      {
        throw new Exception(string.Format("Cannot convert '{0}' to type '{1}'", child.GetType(), typeof (SetterBase)));
      }

      if (_setters == null)
      {
        _setters = new SetterBaseCollection();
      }

      _setters.Add((SetterBase)child);
    }
示例#3
0
        void IAddChild.AddChild(object child)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }

            if (child is SetterBase == false)
            {
                throw new Exception(string.Format("Cannot convert '{0}' to type '{1}'", child.GetType(), typeof(SetterBase)));
            }

            if (_setters == null)
            {
                _setters = new SetterBaseCollection();
            }

            _setters.Add((SetterBase)child);
        }
示例#4
0
 // Token: 0x06000CBD RID: 3261 RVA: 0x0002F8AC File Offset: 0x0002DAAC
 internal void ProcessSettersCollection(SetterBaseCollection setters)
 {
     if (setters != null)
     {
         setters.Seal();
         for (int i = 0; i < setters.Count; i++)
         {
             Setter setter = setters[i] as Setter;
             if (setter == null)
             {
                 throw new InvalidOperationException(SR.Get("VisualTriggerSettersIncludeUnsupportedSetterType", new object[]
                 {
                     setters[i].GetType().Name
                 }));
             }
             DependencyProperty property      = setter.Property;
             object             valueInternal = setter.ValueInternal;
             string             text          = setter.TargetName;
             if (text == null)
             {
                 this.ProcessParametersContainer(property);
                 text = "~Self";
             }
             else
             {
                 text = this.ProcessParametersVisualTreeChild(property, text);
             }
             DynamicResourceExtension dynamicResourceExtension = valueInternal as DynamicResourceExtension;
             if (dynamicResourceExtension == null)
             {
                 this.AddToPropertyValues(text, property, valueInternal, PropertyValueType.Trigger);
             }
             else
             {
                 this.AddToPropertyValues(text, property, dynamicResourceExtension.ResourceKey, PropertyValueType.PropertyTriggerResource);
             }
         }
     }
 }
示例#5
0
        // This will transfer information in the _setters collection to PropertyValues array.
        internal void ProcessSettersCollection(SetterBaseCollection setters)
        {
            // Add information in Setters collection to PropertyValues array.
            if( setters != null )
            {
                // Seal Setters
                setters.Seal();

                for (int i = 0; i < setters.Count; i++ )
                {
                    Setter setter = setters[i] as Setter;
                    if( setter != null )
                    {
                        DependencyProperty dp = setter.Property;
                        object value          = setter.ValueInternal;
                        string target         = setter.TargetName;

                        if( target == null )
                        {
                            ProcessParametersContainer(dp);

                            target = StyleHelper.SelfName;
                        }
                        else
                        {
                            target = ProcessParametersVisualTreeChild(dp, target); // name string will get interned
                        }

                        DynamicResourceExtension dynamicResource = value as DynamicResourceExtension;
                        if (dynamicResource == null)
                        {
                            AddToPropertyValues(target, dp, value, PropertyValueType.Trigger);
                        }
                        else
                        {
                            AddToPropertyValues(target, dp, dynamicResource.ResourceKey, PropertyValueType.PropertyTriggerResource);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException(SR.Get(SRID.VisualTriggerSettersIncludeUnsupportedSetterType, setters[i].GetType().Name));
                    }
                }
            }
        }
示例#6
0
 public Style()
 {
     this.setters = new SetterBaseCollection();
 }
示例#7
0
		public void SetterStillSealedAfterRemove ()
		{
			Setter s = new Setter (UIElement.OpacityProperty, 2.0);
			SetterBaseCollection sbc = new SetterBaseCollection ();
			Assert.IsFalse (sbc.IsSealed, "SetterBaseCollection.IsSealed-1");
			Assert.IsFalse (s.IsSealed, "Setter.IsSealed-1");
			sbc.Add (s);
			Assert.IsFalse (sbc.IsSealed, "SetterBaseCollection.IsSealed-2");
			Assert.IsTrue (s.IsSealed, "Setter.IsSealed-2");
			sbc.Remove (s);
			Assert.IsFalse (sbc.IsSealed, "SetterBaseCollection.IsSealed-3");
			Assert.IsTrue (s.IsSealed, "Setter.IsSealed-3");
		}
示例#8
0
		public void Remove ()
		{
			SetterBaseCollection sbc = new SetterBaseCollection ();
			Assert.IsFalse (sbc.Remove (null), "null");
			Assert.IsFalse (sbc.Remove (new Setter ()), "Empty");
		}
示例#9
0
		public void Add ()
		{
			SetterBaseCollection sbc = new SetterBaseCollection ();
			Assert.Throws<ArgumentNullException> (delegate {
				sbc.Add (null);
			}, "Add(null)");
			Assert.Throws<Exception> (delegate {
				sbc.Add (new Setter ());
			}, "Add(Empty)");
		}