/// <summary> /// Process ATF message and command key by calling the base ProcessCmdKey with converted arguments, /// which allows this key press to be consumed by owning /// controls like PropertyView and PropertyGridView and be seen by ControlHostService. /// Returning false allows the key press to escape to IsInputKey, OnKeyDown, OnKeyUp, etc. /// Returning true means that this key press has been consumed by this method and this /// event is not passed on to any other methods or controls.</summary> /// <param name="msg">ATF message to process</param> /// <param name="keyData">ATF key data</param> /// <returns>False to allow the key press to escape to IsInputKey, OnKeyDown, OnKeyUp, etc. /// True to consume this key press, so this /// event is not passed on to any other methods or controls.</returns> protected virtual bool ProcessCmdKey(ref AtfMessage msg, AtfKeys keyData) { WfMessage wfMsg = MessageInterop.ToWf(msg); return(base.ProcessCmdKey(ref wfMsg, KeysInterop.ToWf(keyData))); }
/// <summary> /// Tests if ATF key is an input key by calling Windows IsInputKey with converted argument</summary> /// <param name="keyData">ATF key data</param> /// <returns>True iff key is an input key</returns> protected virtual bool IsInputKey(AtfKeys keyData) { return(base.IsInputKey(KeysInterop.ToWf(keyData))); }
/// <summary> /// Process Windows message and command key by calling ATF ProcessCmdKey with converted arguments. /// Returning false allows the key press to escape to IsInputKey, OnKeyDown, OnKeyUp, etc. /// Returning true means that this key press has been consumed by this method and this /// event is not passed on to any other methods or controls.</summary> /// <param name="msg">Windows message to process</param> /// <param name="keyData">Windows key data</param> /// <returns>False to allow the key press to escape to IsInputKey, OnKeyDown, OnKeyUp, etc. /// True to consume this key press, so this /// event is not passed on to any other methods or controls.</returns> protected override bool ProcessCmdKey(ref WfMessage msg, WfKeys keyData) { AtfMessage atfMsg = MessageInterop.ToAtf(msg); return(ProcessCmdKey(ref atfMsg, KeysInterop.ToAtf(keyData))); }
/// <summary> /// Converts an enumeration of WfKeys to a string</summary> /// <param name="k">Collection of WfKeys</param> /// <param name="digitOnly">If true, for numeric pad or digit keys, only return /// the number. For example, numpad0 becomes 0, and D0 becomes 0.</param> /// <returns>String representation of the WfKeys enumeration, with each /// WfKeys string separated by a comma and space (", ")</returns> public static string KeysToString(IEnumerable <WfKeys> k, bool digitOnly) { return(Input.KeysUtil.KeysToString(KeysInterop.ToAtf(k), digitOnly)); }
/// <summary> /// Tests if Windows key is an input key by calling ATF IsInputKey with converted argument</summary> /// <param name="keyData">Windows key data</param> /// <returns>True iff key is an input key</returns> protected override bool IsInputKey(WfKeys keyData) { return(IsInputKey(KeysInterop.ToAtf(keyData))); }
/// <summary> /// Returns whether or not the given modifier WfKeys should toggle an item from a selection</summary> /// <param name="modifiers">Modifier WfKeys</param> /// <returns>Whether or not the given modifier WfKeys should toggle an item from a selection</returns> public static bool TogglesSelection(WfKeys modifiers) { return(Input.KeysUtil.TogglesSelection(KeysInterop.ToAtf(modifiers))); }
/// <summary>Converts numeric pad WfKeys to digit WfKeys</summary> /// <param name="keys">WfKeys number pad keys</param> /// <returns>WfKeys digit equivalent</returns> public static WfKeys NumPadToNum(WfKeys keys) { return(KeysInterop.ToWf(Input.KeysUtil.NumPadToNum(KeysInterop.ToAtf(keys)))); }
/// <summary> /// Modifies the given collection with the given items based on standard Windows convention /// of using the Control key to toggle the selection of items, Shift key to add the items, /// and otherwise to set the selection to the items</summary> /// <typeparam name="T">The type of items contained in the selection</typeparam> /// <param name="collection">Collection of already selected items that is modified</param> /// <param name="items">Items to add or remove from collection, or to set the collection to</param> /// <param name="modifiers">Selection modifier WfKeys</param> public static void Select <T>(ICollection <T> collection, IEnumerable <T> items, WfKeys modifiers) { Input.KeysUtil.Select(collection, items, KeysInterop.ToAtf(modifiers)); }
/// <summary> /// Modifies the given collection with the given item based on standard Windows convention /// of using the Control key to toggle the selection of the given item, Shift key to add the /// item, and otherwise to set the selection to the item</summary> /// <typeparam name="T">The type of items contained in the selection</typeparam> /// <param name="collection">Collection of already selected items that is modified</param> /// <param name="item">Item to add or remove from collection</param> /// <param name="modifiers">Selection modifier WfKeys</param> public static void Select <T>(ICollection <T> collection, T item, WfKeys modifiers) { Input.KeysUtil.Select(collection, item, KeysInterop.ToAtf(modifiers)); }
/// <summary> /// Determines whether or not the given WfKeys should be considered a TextBox input and be handled /// by that control. For example, if this method returns true, ProcessCmdKey should return false /// and not call base.ProcessCmdKey.</summary> /// <param name="control">TextBox control. This control (typically a TextBox or ComboBox) is checked to determine if it is multiline, /// which is one of the determinants of the return value.</param> /// <param name="k">WfKeys value</param> /// <returns>Whether or not the given key press should be considered a TextBox input</returns> /// <remarks> /// Some examples from a class deriving from TextBox and what its ProcessCmdKey should do: /// Keypress | IsInputKey | ProcessCmdKey should | Because /// -------- ---------- ------------------------- -------------------------------------- /// s false return false Even if this is a command shortcut, the TextBox input takes priority. /// 1 false return false Even if this is a command shortcut, the TextBox input takes priority. /// F10 false return base.ProcessCmdKey Might be a command shortcut. /// Ctrl+Z false return base.ProcessCmdKey Might be a command shortcut and that takes priority over the TextBox's limited undo. /// Ctrl+C false return false The TextBox copy command takes priority. /// Home true return false The TextBox navigation takes priority. /// Delete false return false The TextBox navigation takes priority. Why does IsInputKey() return false?! .NET bug? /// Up false return false We want our IsInputKey override to receive this. /// </remarks> public static bool IsTextBoxInput(Control control, WfKeys k) { bool isMultiline = (control is TextBoxBase && ((TextBoxBase)control).Multiline); return(Input.KeysUtil.IsTextBoxInput(isMultiline, KeysInterop.ToAtf(k))); }
/// <summary> /// Converts AtfKeyEventArgs to WfKeyEventArgs</summary> /// <param name="args">AtfKeyEventArgs</param> /// <returns>WfKeyEventArgs</returns> public static WfKeyEventArgs ToWf(AtfKeyEventArgs args) { return(new WfKeyEventArgs(KeysInterop.ToWf(args.KeyData))); }
/* * private KeyEventArgsInterop() {} * * * public KeyEventArgsInterop(AtfKeys keys) * { * KeyData = keys; * } * * public KeyEventArgsInterop(AtfKeyEventArgs keyEventArgs) * { * KeyData = keyEventArgs.KeyData; * } * * * public KeyEventArgsInterop(WfKeys keys) * { * KeyData = keys; * } * * public KeyEventArgsInterop(WfKeyEventArgs keyEventArgs) * { * KeyData = keyEventArgs.KeyData; * } * * * public static implicit operator KeyEventArgsInterop(AtfKeys keys) * { * return new KeyEventArgsInterop(keys); * } * * public static implicit operator KeyEventArgsInterop(AtfKeyEventArgs keyEventArgs) * { * return new KeyEventArgsInterop(keyEventArgs); * } * * public static implicit operator KeyEventArgsInterop(WfKeys keys) * { * return new KeyEventArgsInterop(keys); * } * * public static implicit operator KeyEventArgsInterop(WfKeyEventArgs keyEventArgs) * { * return new KeyEventArgsInterop(keyEventArgs); * } * * * public static implicit operator AtfKeys(KeyEventArgsInterop keyEventArgsInterop) * { * return keyEventArgsInterop.KeyData; * } * * public static implicit operator AtfKeyEventArgs(KeyEventArgsInterop keyEventArgsInterop) * { * return new AtfKeyEventArgs(keyEventArgsInterop.KeyData); * } * * public static implicit operator WfKeys(KeyEventArgsInterop keyEventArgsInterop) * { * return keyEventArgsInterop.KeyData; * } * * public static implicit operator WfKeyEventArgs(KeyEventArgsInterop keyEventArgsInterop) * { * return new WfKeyEventArgs(keyEventArgsInterop.KeyData); * } */ /// <summary> /// Converts WfKeyEventArgs to AtfKeyEventArgs</summary> /// <param name="args">WfKeyEventArgs</param> /// <returns>AtfKeyEventArgs</returns> public static AtfKeyEventArgs ToAtf(WfKeyEventArgs args) { return(new AtfKeyEventArgs(KeysInterop.ToAtf(args.KeyData))); }