private void ProcessTick(params Interaction[] interactionsToAdd) { List <InputDevice> usedDevices = new List <InputDevice>(); foreach (Interaction interaction in interactionsToAdd) { InputDevice actionDevice = interaction.SourceDevice; if (usedDevices.Contains(actionDevice)) { throw new ArgumentException("You can only add one action per device for a single tick."); } } List <InputDevice> unusedDevices = new List <InputDevice>(this.sequences.Keys); foreach (Interaction interaction in interactionsToAdd) { ActionSequence sequence = this.FindSequence(interaction.SourceDevice); sequence.AddAction(interaction); unusedDevices.Remove(interaction.SourceDevice); } foreach (InputDevice unusedDevice in unusedDevices) { ActionSequence sequence = this.sequences[unusedDevice]; sequence.AddAction(new PauseInteraction(unusedDevice, TimeSpan.Zero)); } }
private ActionSequence FindSequence(InputDevice device) { if (this.sequences.ContainsKey(device)) { return(this.sequences[device]); } int longestSequenceLength = 0; foreach (KeyValuePair <InputDevice, ActionSequence> pair in this.sequences) { longestSequenceLength = Math.Max(longestSequenceLength, pair.Value.Count); } ActionSequence sequence = new ActionSequence(device, longestSequenceLength); this.sequences[device] = sequence; return(sequence); }