本文整理汇总了C#中Keys.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Keys.ToString方法的具体用法?C# Keys.ToString怎么用?C# Keys.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keys
的用法示例。
在下文中一共展示了Keys.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: A
public bool A(Keys keys)
{
TimeSpan timeSpan = DateTime.Now.Subtract(this.A);
this.A = DateTime.Now;
if (this.A == keys.ToString() && timeSpan.TotalMilliseconds < 100.0)
{
return true;
}
this.A = keys.ToString();
return false;
}
示例2: ToAscii
private static string ToAscii(Keys key)
{
if (key.ToString().ToLower().Contains("oem"))
{
var outputBuilder = new StringBuilder(2);
int result = ToAscii((uint)key, 0, new byte[0], outputBuilder, 0);
if (result == 1)
return (outputBuilder[0].ToString()).ToUpper();
}
return key.ToString();
}
示例3: keyChar
public static char keyChar(Keys key)
{
if (key == Keys.Space)
return ' ';
else if (key == Keys.OemMinus)
return '-';
else if (isKeyDigit(key))
return key.ToString().ElementAt<char>(1);
else if (isKeyLetter(key))
return key.ToString().ElementAt<char>(0);
else
return '\0';
}
示例4: SequenceKeyData
public override byte[] SequenceKeyData(Keys modifier, Keys key)
{
if((int)Keys.F1 <= (int)key && (int)key <= (int)Keys.F12)
return base.SequenceKeyData(modifier, key);
else if(GUtil.IsCursorKey(key))
return base.SequenceKeyData(modifier, key);
else {
byte[] r = new byte[4];
r[0] = 0x1B;
r[1] = (byte)'[';
r[3] = (byte)'~';
//���̂������xterm�ł͊��ƈႤ�悤��
if(key==Keys.Insert)
r[2] = (byte)'2';
else if(key==Keys.Home)
r[2] = (byte)'1';
else if(key==Keys.PageUp)
r[2] = (byte)'5';
else if(key==Keys.Delete)
r[2] = (byte)'3';
else if(key==Keys.End)
r[2] = (byte)'4';
else if(key==Keys.PageDown)
r[2] = (byte)'6';
else
throw new ArgumentException("unknown key " + key.ToString());
return r;
}
}
示例5: Register
/// <summary> register the key hook </summary>
public void Register(Keys hotkey, int modifiers)
{
Unregister();
try
{
// use the GlobalAddAtom API to get a unique ID (as suggested by MSDN docs)
String atomName = Thread.CurrentThread.ManagedThreadId.ToString("X8") + this.GetType().FullName + hotkey.ToString();
this.KeyID = GlobalAddAtom(atomName);
if (this.KeyID == 0)
{
throw new Exception("Unable to generate unique hotkey ID. Error: " + Marshal.GetLastWin32Error().ToString());
}
// register the hotkey, throw if any error
if (!RegisterHotKey(this.handle, (int)this.KeyID, modifiers, (int)hotkey))
{
throw new Exception("Unable to register hotkey. Error: " + Marshal.GetLastWin32Error().ToString());
}
}
catch (Exception e)
{
Log.Write(e);
Unregister();
}
}
示例6: KeyToString
public static String KeyToString(Keys key)
{
switch (key)
{
case Keys.D1:
return "1";
case Keys.D2:
return "2";
case Keys.D3:
return "3";
case Keys.D4:
return "4";
case Keys.D5:
return "5";
case Keys.D6:
return "6";
case Keys.D7:
return "7";
case Keys.D8:
return "8";
case Keys.D9:
return "9";
case Keys.D0:
return "0";
case Keys.LButton:
return Locale.Resource.GenLeftMouse;
case Keys.RButton:
return Locale.Resource.GenRightMouse;
case Keys.MButton:
return Locale.Resource.GenMiddleMouse;
case Keys.None:
return "";
}
return key.ToString();
}
示例7: MainFormKeyPressedEvent
/// <summary>
/// перехват нажимания кнопок
/// </summary>
/// <param name="key">Нажатая кнопка</param>
void MainFormKeyPressedEvent(Keys key)
{
var mod = Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => ModifierKeys.ToString().Split(',').Select(y => y.Trim()).Contains(x.ToString())).ToArray();
curentMod1Key = mod.Length > 0 ? mod[0] : Keys.None;
curentMod2Key = mod.Length > 1 ? mod[1] : Keys.None;
if (key != Keys.ControlKey && key != Keys.ShiftKey)
{
ObjHotKey.mainKey = key;
ObjHotKey.mod1 = curentMod1Key;
ObjHotKey.mod2 = curentMod2Key;
var sb = new StringBuilder(key.ToString());
if (curentMod1Key != Keys.None && curentMod1Key != null)
{
sb.Append(string.Format(" + {0}", curentMod1Key));
ObjHotKey.mod1 = curentMod1Key;
}
if (curentMod2Key != Keys.None && curentMod2Key != null)
{
sb.Append(string.Format(" + {0}", curentMod2Key));
ObjHotKey.mod2 = curentMod2Key;
}
txtbxHotKeyNewValue.Text = sb.ToString();
}
}
示例8: KeyboardProcessing
// Protected Methods (1)
protected void KeyboardProcessing(Keys keyData)
{
if (player.profile.userCanPressArrows && (player.gameState == GameState.Paused || player.gameState == GameState.BeforeFirstMove))
{
player.Pause();
}
if (player.profile.userCanPressArrows && player.gameState == GameState.Running && isKeyDown == false)
{
if (keyData == Keys.Down || keyData == Keys.Up || keyData == Keys.Left || keyData == Keys.Right)
{
Int64 whenMovementIsPossible = Math.Max(player.gameDesk.pSokoban.model.Time, player.gameDesk.pSokoban.TimeMovementEnds);
Debug("(key pressed " + keyData.ToString() + " at time " + player.gameDesk.pSokoban.model.Time.ToString() + ")", "Keyboard");
repeatedSokobanEvent = Keys2EventType(keyData);
if (player.gameDesk.pSokoban.MovementInProgress == false)
{
player.gameDesk.pSokoban.model.MakePlan(player.model.time, player.gameDesk.pSokoban, repeatedSokobanEvent);
player.gameDesk.pSokoban.MovementInProgress = true;
}
}
DEBUG_KeysProcessing(keyData);
}
}
示例9:
public string this[Keys key]
{
get
{
return _data[key.ToString()];
}
}
示例10: SetValue
private static void SetValue(Keys keys, object value)
{
if (value == null)
value = string.Empty;
Registry.SetValue(APP_KEY, keys.ToString(), value.ToString());
}
示例11: keyboard
public override String keyboard(Keys keyCode, int x, int y)
{
StringBuilder result = new StringBuilder();
switch (keyCode)
{
case Keys.B:
boneToUpdate++;
if (boneToUpdate > (bones.Count - 1))
{
boneToUpdate = 0;
}
result.AppendLine("boneToUpdate = " + boneToUpdate.ToString());
break;
case Keys.D1: Rotate(Vector3.UnitX, 5f); break;
case Keys.D2: Rotate(Vector3.UnitX, -5f); break;
case Keys.D3: Rotate(Vector3.UnitY, 5f); break;
case Keys.D4: Rotate(Vector3.UnitY, -5f); break;
case Keys.D5: Rotate(Vector3.UnitZ, 5f); break;
case Keys.D6: Rotate(Vector3.UnitZ, -5f); break;
case Keys.D7: Scale(new Vector3(0.9f, 0.9f, 0.9f)); break;
case Keys.D8: Scale(new Vector3(1.1f, 1.1f, 1.1f)); break;
case Keys.D9: Move(new Vector3(0.1f, 0.1f, 0.1f)); break;
case Keys.D0: Move(new Vector3(-0.1f, -0.1f, -0.1f)); break;
case Keys.I:
foreach(Bone b in bones)
{
result.Append(b.GetBoneInfo());
}
break;
}
result.AppendLine(keyCode.ToString());
return result.ToString();
}
示例12: ProcessCmdKey
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (waitLabel != null)
{
if (!keyData.HasFlag(Keys.Control) && !keyData.HasFlag(Keys.Alt) && !keyData.HasFlag(Keys.Shift))
{
switch (waitKey)
{
case GameInput.Up: GameInputKeys.Up = keyData; break;
case GameInput.Down: GameInputKeys.Down = keyData; break;
case GameInput.Left: GameInputKeys.Left = keyData; break;
case GameInput.Right: GameInputKeys.Right = keyData; break;
case GameInput.Jump: GameInputKeys.Jump = keyData; break;
case GameInput.Shoot: GameInputKeys.Shoot = keyData; break;
case GameInput.Start: GameInputKeys.Start = keyData; break;
case GameInput.Select: GameInputKeys.Select = keyData; break;
}
waitLabel.Text = keyData.ToString();
waitLabel = null;
return true; // Needs to be here, so if a key picked like up, selected button must not be changed.
}
else
{
string key = "";
if (keyData.HasFlag(Keys.Control)) key = "ctrl";
else if (keyData.HasFlag(Keys.Alt)) key = "Alt";
else if (keyData.HasFlag(Keys.Shift)) key = "Shift";
MessageBox.Show(this, "Key " + key + " is not allowed.", "Unhauthorized key", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
示例13: HotkeyForm
public HotkeyForm()
{
InitializeComponent();
MainForm.HotkeyEnabled = false;
switch (MainForm.HotkeyAction)
{
case HotkeyActions.AddStart:
radioButton_AddStart.Checked = true;
break;
case HotkeyActions.AddEnd:
radioButton_AddEnd.Checked = true;
break;
case HotkeyActions.AddRange:
radioButton_AddRange.Checked = true;
break;
case HotkeyActions.SubStart:
radioButton_SubStart.Checked = true;
break;
case HotkeyActions.SubEnd:
radioButton_SubEnd.Checked = true;
break;
case HotkeyActions.SubRange:
radioButton_SubRange.Checked = true;
break;
}
Hotkey = MainForm.Hotkey;
label_HotkeyKey.Text = Hotkey.ToString();
}
示例14: GetValueOf
public static string GetValueOf(Keys k)
{
if ((int)k >= 65 && (int)k <= 90)
{
return k.ToString().ToLower();
}
else if (k == (Keys)48 || k == (Keys)96)
{
return "0";
}
else if (k == (Keys)49 || k == (Keys)97)
{
return "1";
}
else if (k == (Keys)50 || k == (Keys)98)
{
return "2";
}
else if (k == (Keys)51 || k == (Keys)99)
{
return "3";
}
else if (k == (Keys)52 || k == (Keys)100)
{
return "4";
}
else if (k == (Keys)53 || k == (Keys)101)
{
return "5";
}
else if (k == (Keys)54 || k == (Keys)102)
{
return "6";
}
else if (k == (Keys)55 || k == (Keys)103)
{
return "7";
}
else if (k == (Keys)56 || k == (Keys)104)
{
return "8";
}
else if (k == (Keys)57 || k == (Keys)105)
{
return "9";
}
else if (k == (Keys)57 || k == (Keys)106)
{
return "9";
}
else if (k == (Keys)110)
{
return ".";
}
else
{
return "";
}
}
示例15: OptionsForm
public OptionsForm(Keys increaseHotkey, Keys decreaseHotkey)
{
InitializeComponent();
increaseHotkeyBox.Text = increaseHotkey.ToString();
IncreaseHotkey = increaseHotkey;
decreaseHotkeyBox.Text = decreaseHotkey.ToString();
DecreaseHotkey = decreaseHotkey;
}