예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MacroCode"/> class.
 /// </summary>
 /// <param name="Trigger">The trigger that run the method.</param>
 /// <param name="Method">The method to run.</param>
 /// <param name="Target">The target instance.</param>
 public MacroCode(GeneralTrigger Trigger, MethodInfo Method, object Target)
 {
     //set the target instance
     target = Target;
     //set the parameter count to zero since all user code triggers take zero args
     param = new object[0];
     trigger = Trigger;
     method = DynamicMethodDelegateFactory.Create(Method);
     this.IsSuspended = true;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerAttribute"/> class.
 /// </summary>
 /// <param name="TimerInterval">The timer interval.</param>
 public TriggerAttribute(int TimerInterval)
 {
     eventdata = new TimerTrigger(TimerInterval);
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerAttribute"/> class.
 /// </summary>
 /// <param name="Action">The action.</param>
 public TriggerAttribute(WheelActions Action)
 {
     eventdata = new MouseWheelTrigger(Action);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerAttribute"/> class.
 /// </summary>
 /// <param name="Button">The button.</param>
 /// <param name="Action">The action.</param>
 public TriggerAttribute(MouseButtons Button, InputActions Action)
 {
     eventdata = new MouseButtonTrigger(Button, Action);
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerAttribute"/> class.
 /// </summary>
 /// <param name="Key">The key.</param>
 /// <param name="Action">The action.</param>
 public TriggerAttribute(Keys Key, InputActions Action)
 {
     eventdata = new KeyboardTrigger(Key, Action);
 }
예제 #6
0
        //could use the params keyword on this method
        private void Run(EventTypes EventType, GeneralTrigger Trigger)
        {
            try
            {
                //try running the method in the user code.
                method.Invoke(target, param);
            }
            catch (Exception ex)
            {
                //if the user code throws an exception.
                //stop it from doing it again.
                this.IsSuspended  = true;

                //notify subscribers an error has occurred.
                ErrorOccured.Invoke(ex);
            }
        }
예제 #7
0
 //runs when the trigger for this macro fires
 void OnEventFired(EventTypes EventType, GeneralTrigger Trigger)
 {
     //run the user code
     Run(EventType, Trigger);
 }
예제 #8
0
 /// <summary>
 /// Called when the event is triggered.
 /// </summary>
 /// <param name="TriggerType">Type of the trigger.</param>
 /// <param name="Trigger">The trigger.</param>
 protected virtual void OnEventTriggered(EventTypes TriggerType, GeneralTrigger Trigger)
 {
     if (EventFired != null)
         EventFired.Invoke(TriggerType, Trigger);
 }