#region Using Directives
using System;
using System.Windows.Forms;
#endregion Using Directives
namespace ScintillaNET
{
///
/// Represents the Binding Combination of a Keyboard Key + Modifiers
///
public struct KeyBinding
{
#region Fields
private Keys _keycode;
private Keys _modifiers;
#endregion Fields
#region Methods
///
/// Overridden.
///
/// Another KeyBinding struct
/// True if the Keycode and Modifiers are equal
public override bool Equals(object obj)
{
if (!(obj is KeyBinding))
return false;
KeyBinding kb = (KeyBinding)obj;
return _keycode == kb._keycode && _modifiers == kb._modifiers;
}
///
/// Overridden
///
/// Hashcode of ToString()
public override int GetHashCode()
{
return ToString().GetHashCode();
}
///
/// Overridden. Returns string representation of the Keyboard shortcut
///
/// Returns string representation of the Keyboard shortcut
public override string ToString()
{
return ((int)_keycode).ToString() + ((int)_modifiers).ToString();
}
#endregion Methods
#region Properties
///
/// Gets/Sets Key to trigger command
///
public Keys KeyCode
{
get
{
return _keycode;
}
set
{
_keycode = value;
}
}
///
/// Gets sets key modifiers to the Keyboard shortcut
///
public Keys Modifiers
{
get
{
return _modifiers;
}
set
{
_modifiers = value;
}
}
#endregion Properties
#region Constructors
///
/// Initializes a new instance of the KeyBinding structure.
///
/// Key to trigger command
/// key modifiers to the Keyboard shortcut
public KeyBinding(Keys keycode, Keys modifiers)
{
_keycode = keycode;
_modifiers = modifiers;
}
#endregion Constructors
}
}