35 lines
944 B
C#
35 lines
944 B
C#
|
|
namespace AutoAgent.Domain.Models
|
|||
|
|
{
|
|||
|
|
public class KeyShortcutSequence
|
|||
|
|
{
|
|||
|
|
private Queue<KeyValuePair<KeyShortcut, uint>> _queue = new();
|
|||
|
|
|
|||
|
|
public KeyShortcutSequence(KeyShortcut key) { Next(key); }
|
|||
|
|
|
|||
|
|
public KeyShortcutSequence Next(KeyShortcut shortcut, int delay = 0)
|
|||
|
|
{
|
|||
|
|
_queue.Enqueue(new KeyValuePair<KeyShortcut, uint>(shortcut, (uint)delay));
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IEnumerable<InputAction> GetInputActions()
|
|||
|
|
{
|
|||
|
|
var actions = new InputAction[0];
|
|||
|
|
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
var kvpair = _queue.Dequeue();
|
|||
|
|
|
|||
|
|
if (actions.Length > 0)
|
|||
|
|
{
|
|||
|
|
actions[actions.Length - 1].DelayMs += kvpair.Value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
actions = actions.Concat(kvpair.Key.GetInputActions()).ToArray();
|
|||
|
|
} while (_queue.Count > 0);
|
|||
|
|
|
|||
|
|
return actions;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|