Event handlers are regular methods like any others.
The reason you can't call it like you're trying to do, is because the MouseDown
event takes a MouseButtonEventArgs
instance, while the Tick
event of timers take the base class EventArgs
.
You'll need to create a new instance of MouseButtonEventArgs
, but then you'll need to initialize it with a device, and other event data.
A better option would be to refactor the body of the MouseDown
event handler to a method taking individual parameters, which you can then call without having to create a MouseButtonEventArgs
instance.
private void image1_MouseDown(object sender, MouseButtonEventArgs e)
{
this.ProcessImageMouseDown(e.ChangedButton, e.ButtonState, e.GetPosition(sender as FrameworkElement));
}
private void timerTick(object sender, EventArgs e)
{
this.ProcessImageMouseDown(MouseButton.Left, MouseButtonState.Pressed, new Point(10d, 20d));
}
private void ProcessImageMouseDown(MouseButton button, MouseButtonState state, System.Windows.Point position)
{
// Do actual processing here.
}