public bool Contains(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } return(List.Contains(action)); }
public int IndexOf(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } return(List.IndexOf(action)); }
public void CopyTo(TriggerAction[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } List.CopyTo(array, arrayIndex); }
public void Add(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } List.Add(action); }
public void Insert(int index, TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } List.Insert(index, action); }
public bool Contains(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } return List.Contains(action); }
/// <summary> /// Add an object child to this trigger's Actions /// </summary> protected virtual void AddChild(object value) { TriggerAction action = value as TriggerAction; if (action == null) { throw new ArgumentException(SR.Get(SRID.EventTriggerBadAction, value.GetType().Name)); } Actions.Add(action); }
/// <summary>Adds the specified object to the <see cref="P:System.Windows.EventTrigger.Actions" /> collection of the current event trigger.</summary> /// <param name="value">A <see cref="T:System.Windows.TriggerAction" /> object to add to the <see cref="P:System.Windows.EventTrigger.Actions" /> collection of this trigger.</param> // Token: 0x060003E8 RID: 1000 RVA: 0x0000B2CC File Offset: 0x000094CC protected virtual void AddChild(object value) { TriggerAction triggerAction = value as TriggerAction; if (triggerAction == null) { throw new ArgumentException(SR.Get("EventTriggerBadAction", new object[] { value.GetType().Name })); } this.Actions.Add(triggerAction); }
public bool Remove(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } if (List.Contains(action) == false) { return(false); } List.Remove(action); return(true); }
private System.Windows.TriggerAction CreateTriggerAction(StyleSheet styleSheet, DependencyObject styleResourceReferenceHolder, TriggerAction action) { string actionTypeName = null; Type actionType = null; System.Windows.TriggerAction nativeTriggerAction = null; actionTypeName = typeNameResolver.ResolveFullTypeName(styleSheet.Namespaces, action.Action); actionType = Type.GetType(actionTypeName); nativeTriggerAction = (System.Windows.TriggerAction)Activator.CreateInstance(actionType); foreach (var parameter in action.Parameters) { string parameterName = null; object value = null; string parameterValueExpression = null; DependencyPropertyInfo <DependencyProperty> propertyInfo; Type type = null; parameterName = parameter.Property; parameterValueExpression = parameter.Value.Trim(); type = typeNameResolver.GetClrPropertyType(styleSheet.Namespaces, nativeTriggerAction, parameterName); if (typeNameResolver.IsMarkupExtension(parameterValueExpression)) { value = typeNameResolver.GetMarkupExtensionValue(styleResourceReferenceHolder, parameterValueExpression, styleSheet.Namespaces, false); } else if ((propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, actionType, parameterName)) != null) { value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, parameterValueExpression, propertyInfo.Property, styleSheet.Namespaces); if (value is DynamicResourceExtension) { var dyn = value as DynamicResourceExtension; serviceProvider = serviceProvider ?? (serviceProvider = (IServiceProvider)typeof(Application).GetProperty("ServiceProvider", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Application.Current)); value = dyn.ProvideValue(serviceProvider); } else if (value is StaticResourceExtension) { var dyn = value as StaticResourceExtension; serviceProvider = serviceProvider ?? (serviceProvider = (IServiceProvider)typeof(Application).GetProperty("ServiceProvider", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Application.Current)); value = dyn.ProvideValue(serviceProvider); } } else { value = parameterValueExpression; } if (value is string valueString) { value = TypeDescriptor.GetConverter(type)?.ConvertFromInvariantString(valueString) ?? value; } if (value == null) { } dependencyService.SetValue(nativeTriggerAction, parameterName, value); } return(nativeTriggerAction); }
public override DependencyObject CreateTrigger(StyleSheet styleSheet, ITrigger trigger, Type targetType, DependencyObject styleResourceReferenceHolder) { if (trigger == null) { throw new ArgumentNullException(nameof(trigger)); } if (trigger is Trigger) { var propertyTrigger = trigger as Trigger; var nativeTrigger = new System.Windows.Trigger(); var dependencyProperty = dependencyService.GetDependencyProperty(targetType, propertyTrigger.Property); if (dependencyProperty == null) { throw new NullReferenceException($"Property '{propertyTrigger.Property}' may not be null (targetType '{targetType.Name}')!"); } nativeTrigger.Property = dependencyProperty; nativeTrigger.Value = dependencyService.GetDependencyPropertyValue(targetType, nativeTrigger.Property.Name, nativeTrigger.Property, propertyTrigger.Value); foreach (var styleDeclaration in propertyTrigger.StyleDeclarationBlock) { var propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, targetType, styleDeclaration.Property); if (propertyInfo == null) { continue; } try { var value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, styleSheet.Namespaces); if (value == null) { } nativeTrigger.Setters.Add(new Setter { Property = propertyInfo.Property, Value = value }); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value} - {styleDeclaration.Property}: {styleDeclaration.Value}"": {e.Message}"); } } foreach (var action in propertyTrigger.EnterActions) { try { var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action); nativeTrigger.EnterActions.Add(nativeTriggerAction); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value}"" enter action: {e.Message}"); } } foreach (var action in propertyTrigger.ExitActions) { try { var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action); nativeTrigger.ExitActions.Add(nativeTriggerAction); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value}"" exit action: {e.Message}"); } } var serialized = SerializeObject(nativeTrigger); //serialized = $"pre XamlWriter.Save({nativeTrigger.GetType().Name})".Measure(() => XamlWriter.Save(nativeTrigger)); Css.SetSerializedTrigger(nativeTrigger, serialized); return(nativeTrigger); } else if (trigger is DataTrigger) { var dataTrigger = trigger as DataTrigger; var nativeTrigger = new System.Windows.DataTrigger(); string expression = null; if (typeNameResolver.IsMarkupExtension(dataTrigger.Binding)) { expression = typeNameResolver.CreateMarkupExtensionExpression(dataTrigger.Binding); } else { expression = "{Binding " + dataTrigger.Binding + "}"; } var binding = (System.Windows.Data.BindingBase)markupExtensionParser.ProvideValue(expression, null, styleSheet.Namespaces); nativeTrigger.Binding = binding; nativeTrigger.Value = GetBasicValue(dataTrigger); foreach (var styleDeclaration in dataTrigger.StyleDeclarationBlock) { try { var propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, targetType, styleDeclaration.Property); if (propertyInfo == null) { continue; } var value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, styleSheet.Namespaces); if (value == null) { } nativeTrigger.Setters.Add(new Setter { Property = propertyInfo.Property, Value = value }); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {styleDeclaration.Property}: {styleDeclaration.Value}"": {e.Message}"); } } foreach (var action in dataTrigger.EnterActions) { try { System.Windows.TriggerAction nativeTriggerAction = null; nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action); nativeTrigger.EnterActions.Add(nativeTriggerAction); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {action}"" enter action: {e.Message}"); } } foreach (var action in dataTrigger.ExitActions) { try { var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action); nativeTrigger.ExitActions.Add(nativeTriggerAction); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {action}"" exit action: {e.Message}"); } } var serialized = SerializeObject(nativeTrigger); //serialized = $"pre XamlWriter.Save({nativeTrigger.GetType().Name})".Measure(() => XamlWriter.Save(nativeTrigger)); Css.SetSerializedTrigger(nativeTrigger, serialized); return(nativeTrigger); } else if (trigger is EventTrigger) { var eventTrigger = trigger as EventTrigger; var nativeTrigger = new System.Windows.EventTrigger(); nativeTrigger.RoutedEvent = (RoutedEvent)TypeHelpers.GetFieldValue(targetType, eventTrigger.Event + "Event"); foreach (var action in eventTrigger.Actions) { try { var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action); nativeTrigger.Actions.Add(nativeTriggerAction); } catch (Exception e) { styleSheet.Errors.Add($@"ERROR in event trigger ""{eventTrigger.Event} {action.Action}"": {e.Message}"); } } var serialized = SerializeObject(nativeTrigger); //serialized = $"pre XamlWriter.Save({nativeTrigger.GetType().Name})".Measure(() => XamlWriter.Save(nativeTrigger)); Css.SetSerializedTrigger(nativeTrigger, serialized); return(nativeTrigger); } throw new NotSupportedException($"Trigger '{trigger.GetType().FullName}' is not supported!"); }
public int IndexOf(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } return List.IndexOf(action); }
public bool Remove(TriggerAction action) { if (action == null) { throw new ArgumentNullException("action"); } if (List.Contains(action) == false) { return false; } List.Remove(action); return true; }