using System; using System.Windows; namespace OpenSEMI.ClientBase.Command { public class EventCommandParameter : CommandParameter where TEventArgs : RoutedEventArgs { public RoutedEvent RoutedEvent { get; private set; } public TEventArgs EventArgs { get; private set; } public EventCommandParameter(TCustomParameter customParameter, RoutedEvent routedEvent, TEventArgs eventArgs) : base(customParameter) { RoutedEvent = routedEvent; EventArgs = eventArgs; } public new static EventCommandParameter Cast(object parameter) { EventCommandParameter eventCommandParameter = parameter as EventCommandParameter; if (eventCommandParameter == null) { throw new InvalidCastException($"Failed to case {parameter.GetType()} to {typeof(EventCommandParameter)}"); } return new EventCommandParameter((TCustomParameter)eventCommandParameter.CustomParameter, eventCommandParameter.RoutedEvent, (TEventArgs)eventCommandParameter.EventArgs); } } }