public override string GetCodeStr(IKeyGetter keyGetter) { string result = string.Empty; for (int column = 0; column < Hardware.Keyboard.NumColumns; column++) { byte thisValue = 0; for (int row = 0; row < Hardware.Keyboard.NumRows; row++) { if (Hardware.Keyboard.IsValidKey(column, row)) { KeyBase xkey = keyGetter.GetKey(column, row); if (!xkey.IsDown) { continue; } KeyBase singleXkey = keyGetter.GetSingleKey(column, row); if (singleXkey != null) { thisValue += singleXkey.GetRowDataValue(); } } } result += thisValue + "."; } return(result.TrimEnd('.')); }
public override List <KeyBase> GetPressedKeys(string customData, IKeyGetter keyGetter) { List <KeyBase> keysPressed = new List <KeyBase>(); string[] columns = customData.Split('.'); for (int column = 0; column < columns.Length; column++) { int value; if (int.TryParse(columns[column], out value)) { if (value == 0) { continue; } for (int row = 0; row < Hardware.Keyboard.NumRows; row++) { byte rowMask = (byte)(Math.Pow(2, row)); if ((rowMask & value) == rowMask) { KeyBase keyPressed = keyGetter.GetKey(column, row); if (keysPressed.Contains(keyPressed)) { continue; } keysPressed.Add(keyPressed); } } } } return(keysPressed); }
public DocumentCollection(CollectionConfiguration configuration) { Configuration = configuration; //todo: передавать снаружи ConfigurationTyped = (configuration as CollectionConfigurationTyped <T>) ?? new CollectionConfigurationTyped <T>(); _keyGetter = ConfigurationTyped.KeyGetter; _keySetter = ConfigurationTyped.KeySetter; }
/// <summary> /// Returns a coded string based on the keys that are currently down. This same /// coded string can be used later, passed to GetPressedKeys, above, to return /// a collection of keys that were pressed. /// </summary> public abstract string GetCodeStr(IKeyGetter keyGetter);
/// <summary> /// Gets a collection of pressed keys based on the coded data string customData. /// </summary> public abstract List <KeyBase> GetPressedKeys(string customData, IKeyGetter keyGetter);
public event OptionSelectedHandler OptionSelected; // Option selected event public Menu(IDisplay display, IKeyGetter keyGetter) // Dependency injection for testability. { _display = display; _keyGetter = keyGetter; }