protected override void OnInitialized() { TProperty minProperty = (TProperty)Owner[this.minPropertyName]; TProperty maxProperty = (TProperty)Owner[this.maxPropertyName]; if (ScalarProperty <TValue> .IsGreaterThan(minProperty.MinValue, maxProperty.MinValue)) { throw new ArgumentOutOfRangeException("MinProperty.MinValue must be less than or equal to MaxProperty.MinValue"); } if (ScalarProperty <TValue> .IsGreaterThan(minProperty.MaxValue, maxProperty.MaxValue)) { throw new ArgumentOutOfRangeException("MinProperty.MaxValue must be less than or equal to MaxProperty.MaxValue"); } // Analyze the PropertyCollection we are bound to in order to ensure that we do not // have any "infinite loops". It is safe to simply ensure that no other SoftMutuallyBoundMinMaxRule // has minPropertyName as a maxPropertyName. foreach (PropertyCollectionRule rule in this.Owner.Rules) { SoftMutuallyBoundMinMaxRule <TValue, TProperty> asOurRule = rule as SoftMutuallyBoundMinMaxRule <TValue, TProperty>; if (asOurRule != null) { if (asOurRule.maxPropertyName.ToString() == this.minPropertyName.ToString()) { throw new ArgumentException("The graph of SoftMutuallyBoundMinMaxRule's in the PropertyCollection has a cycle in it"); } } } minProperty.ValueChanged += new EventHandler(MinProperty_ValueChanged); maxProperty.ValueChanged += new EventHandler(MaxProperty_ValueChanged); }
protected override void OnInitialized() { // Verify the sourcePropertyName is not in targetPropertyNames if (-1 != Array.IndexOf(this.targetPropertyNames, this.sourcePropertyName)) { throw new ArgumentException("sourceProperty may not be in the list of targetProperties"); } // Verify that the intersection of this rule's targetProperty and that of all the other Link*'d rules is empty Set <string> ourTargetPropertyNamesSet = null; foreach (PropertyCollectionRule rule in Owner.Rules) { var asLinkRule = rule as LinkValuesBasedOnBooleanRule <TValue, TProperty>; if (asLinkRule != null && !object.ReferenceEquals(this, asLinkRule)) { if (ourTargetPropertyNamesSet == null) { ourTargetPropertyNamesSet = new Set <string>(this.targetPropertyNames); } Set <string> theirTargetPropertyNamesSet = new Set <string>(asLinkRule.targetPropertyNames); Set <string> intersection = Set <string> .Intersect(ourTargetPropertyNamesSet, theirTargetPropertyNamesSet); if (intersection.Count != 0) { throw new ArgumentException("Cannot assign a property to be linked with more than one LinkValuesBasedOnBooleanRule instance"); } } } // Verify every property is of type TProperty // That all the ranges are the same // Sign up for events TProperty firstProperty = (TProperty)this.Owner[this.targetPropertyNames[0]]; foreach (string targetPropertyName in this.targetPropertyNames) { TProperty targetProperty = (TProperty)this.Owner[targetPropertyName]; if (!(targetProperty is TProperty)) { throw new ArgumentException("All of the target properties must be of type TProperty (" + typeof(TProperty).FullName + ")"); } if (!ScalarProperty <TValue> .IsEqualTo(targetProperty.MinValue, firstProperty.MinValue) || !ScalarProperty <TValue> .IsEqualTo(targetProperty.MaxValue, firstProperty.MaxValue)) { throw new ArgumentException("All of the target properties must have the same min/max range"); } targetProperty.ValueChanged += new EventHandler(TargetProperty_ValueChanged); } BooleanProperty sourceProperty = (BooleanProperty)this.Owner[sourcePropertyName]; sourceProperty.ValueChanged += new EventHandler(SourceProperty_ValueChanged); Sync(); }
public bool IsEqualTo(ScalarProperty <T> rhs) { return(IsEqualTo(this, rhs)); }
public static bool IsEqualTo(ScalarProperty <T> lhs, ScalarProperty <T> rhs) { return(IsEqualTo(lhs.Value, rhs.Value)); }
public static bool IsGreaterThan(ScalarProperty <T> lhs, ScalarProperty <T> rhs) { return(IsGreaterThan(lhs.Value, rhs.Value)); }
public bool IsGreaterThan(ScalarProperty <T> rhs) { return(IsGreaterThan(this, rhs)); }
public bool IsLessThan(ScalarProperty <T> rhs) { return(IsLessThan(this, rhs)); }
internal ScalarProperty(ScalarProperty <T> copyMe, ScalarProperty <T> sentinelNotUsed) : base(copyMe, sentinelNotUsed) { this.minValue = copyMe.minValue; this.maxValue = copyMe.maxValue; }
public T ClampPotentialValueY(T newValue) { return(ScalarProperty <T> .Clamp(newValue, this.MinValueY, this.MaxValueY)); }