|
|
|
@ -44,53 +44,54 @@ public static class HeadlessWindowExtensions |
|
|
|
/// Simulates keyboard press on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void KeyPress(this TopLevel topLevel, Key key, RawInputModifiers modifiers) => |
|
|
|
RunJobsAndGetImpl(topLevel).KeyPress(key, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.KeyPress(key, modifiers)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Simulates keyboard release on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void KeyRelease(this TopLevel topLevel, Key key, RawInputModifiers modifiers) => |
|
|
|
RunJobsAndGetImpl(topLevel).KeyRelease(key, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.KeyRelease(key, modifiers)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Simulates mouse down on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void MouseDown(this TopLevel topLevel, Point point, MouseButton button, |
|
|
|
RawInputModifiers modifiers = RawInputModifiers.None) => |
|
|
|
RunJobsAndGetImpl(topLevel).MouseDown(point, button, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.MouseDown(point, button, modifiers)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Simulates mouse move on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void MouseMove(this TopLevel topLevel, Point point, |
|
|
|
RawInputModifiers modifiers = RawInputModifiers.None) => |
|
|
|
RunJobsAndGetImpl(topLevel).MouseMove(point, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.MouseMove(point, modifiers)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Simulates mouse up on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void MouseUp(this TopLevel topLevel, Point point, MouseButton button, |
|
|
|
RawInputModifiers modifiers = RawInputModifiers.None) => |
|
|
|
RunJobsAndGetImpl(topLevel).MouseUp(point, button, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.MouseUp(point, button, modifiers)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Simulates mouse wheel on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void MouseWheel(this TopLevel topLevel, Point point, Vector delta, |
|
|
|
RawInputModifiers modifiers = RawInputModifiers.None) => |
|
|
|
RunJobsAndGetImpl(topLevel).MouseWheel(point, delta, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.MouseWheel(point, delta, modifiers)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Simulates drag'n'drop target on the headless window/toplevel.
|
|
|
|
/// </summary>
|
|
|
|
public static void DragDrop(this TopLevel topLevel, Point point, RawDragEventType type, IDataObject data, |
|
|
|
DragDropEffects effects, RawInputModifiers modifiers = RawInputModifiers.None) => |
|
|
|
RunJobsAndGetImpl(topLevel).DragDrop(point, type, data, effects, modifiers); |
|
|
|
RunJobsOnImpl(topLevel, w => w.DragDrop(point, type, data, effects, modifiers)); |
|
|
|
|
|
|
|
private static IHeadlessWindow RunJobsAndGetImpl(this TopLevel topLevel) |
|
|
|
private static void RunJobsOnImpl(this TopLevel topLevel, Action<IHeadlessWindow> action) |
|
|
|
{ |
|
|
|
Dispatcher.UIThread.RunJobs(); |
|
|
|
return GetImpl(topLevel); |
|
|
|
action(GetImpl(topLevel)); |
|
|
|
Dispatcher.UIThread.RunJobs(); |
|
|
|
} |
|
|
|
|
|
|
|
private static IHeadlessWindow GetImpl(this TopLevel topLevel) |
|
|
|
|