Volume Control
Application-specific hotkeys for Windows
VolumeControl.Core.Extensions.KeyExtensions Class Reference

Defines extension methods for various types of Key/ModifierKey enumerations. More...

Collaboration diagram for VolumeControl.Core.Extensions.KeyExtensions:

Static Public Member Functions

static Key ToKey (this ModifierKeys modifierKey, bool useLeftSideKey=true)
 Gets the Key associated with this ModifierKeys value. More...
 
static IEnumerable< Key > ToKeys (this ModifierKeys modifierKeys, bool useLeftSideKey=true)
 Gets the Key values associated with this ModifierKeys value. More...
 
static EModifierKey SetFlagState (this EModifierKey m, EModifierKey flag, bool state)
 Sets or unsets the bit specified by flag in ref m . More...
 
static string GetStringRepresentation (this EModifierKey m, bool insertSpaces=false, char separator='+', bool includeNone=false)
 Gets the string representation of the EModifierKey specified by m . More...
 

Detailed Description

Defines extension methods for various types of Key/ModifierKey enumerations.

Member Function Documentation

◆ GetStringRepresentation()

static string VolumeControl.Core.Extensions.KeyExtensions.GetStringRepresentation ( this EModifierKey  m,
bool  insertSpaces = false,
char  separator = '+',
bool  includeNone = false 
)
static

Gets the string representation of the EModifierKey specified by m .

Parameters
mEModifierKey
insertSpacesWhen true, inserts spaces between the enum names & the separator characters.
separatorThe separator character to use between enum names.
includeNoneWhen the modifier key is EModifierKey.None and this is true, the returned string is "None"; otherwise, returns a blank string.
Returns
The string representation of m in the form "Shift+Ctrl+Alt".

◆ SetFlagState()

static EModifierKey VolumeControl.Core.Extensions.KeyExtensions.SetFlagState ( this EModifierKey  m,
EModifierKey  flag,
bool  state 
)
static

Sets or unsets the bit specified by flag in ref m .

Parameters
mEModifierKey
flagThe modifier to add/remove.
stateWhen true, flag is set to 1; when false, flag is set to 0.
Returns
The resulting EModifierKey.

◆ ToKey()

static Key VolumeControl.Core.Extensions.KeyExtensions.ToKey ( this ModifierKeys  modifierKey,
bool  useLeftSideKey = true 
)
static

Gets the Key associated with this ModifierKeys value.

The modifier key value must contain exactly one flag value or an InvalidOperationException will be thrown.

Parameters
modifierKey(implicit) The enum value to operate on.
useLeftSideKeyWhen true, the left-side variants of the key are returned; otherwise, the right-side variants are returned.
Returns
The Key value representing the ModifierKeys value.
Exceptions
InvalidEnumArgumentExceptionThe specified modifierKey was not a valid value for the ModifierKeys enumeration.
InvalidOperationExceptionThe specified modifierKey was not a single flag value from the ModifierKeys enumeration.

◆ ToKeys()

static IEnumerable<Key> VolumeControl.Core.Extensions.KeyExtensions.ToKeys ( this ModifierKeys  modifierKeys,
bool  useLeftSideKey = true 
)
static

Gets the Key values associated with this ModifierKeys value.

Unlike the ToKey method, this can accept ModifierKeys values that have more than one flag set.

Parameters
modifierKeys(implicit) The enum value to operate on.
useLeftSideKeyWhen true, the left-side variants of the key are returned; otherwise, the right-side variants are returned.
Returns
The Key values representing all of the flags that were set in the ModifierKeys value.

The documentation for this class was generated from the following file: