本文整理汇总了C#中Keys.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Keys.Equals方法的具体用法?C# Keys.Equals怎么用?C# Keys.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keys
的用法示例。
在下文中一共展示了Keys.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendKey
public void SendKey(int keyValue, Keys modifiers)
{
VirtualKeyCode key;
if (modifiers.Equals(Keys.None))
{
if (Enum.TryParse(VkKeyScan(((char)keyValue)).ToString(), out key))
{
InputSimulator.SimulateKeyDown(key);
InputSimulator.SimulateKeyUp(key);
}
}
else if (modifiers.Equals(Keys.Shift) && keyValue >= (int)Keys.A && keyValue <= (int)Keys.Z)
{
if (Enum.TryParse(VkKeyScan(((char)keyValue)).ToString(), out key))
{
InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.SHIFT, key);
}
}
else if (modifiers.Equals(Keys.Control) && keyValue >= (int)Keys.A && keyValue <= (int)Keys.Z)
{
if (Enum.TryParse(VkKeyScan(((char)keyValue)).ToString(), out key))
{
InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, key);
}
}
else if (modifiers.Equals(Keys.Alt) && keyValue >= (int)Keys.A && keyValue <= (int)Keys.Z)
{
if (Enum.TryParse(VkKeyScan(((char)keyValue)).ToString(), out key))
{
//Alt is named MENU for legacy purposes.
InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.MENU, key);
}
}
}
示例2: ProcessCmdKey
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// http://support.microsoft.com/kb/320584
const int WM_KEYDOWN = 0x100;
if (msg.Msg == WM_KEYDOWN)
{
if (keyData.Equals(Keys.Control | Keys.A))
{
base.SelectAll();
return true;
}
if (keyData.Equals(Keys.Control | Keys.Back))
{
if (SelectionStart - 1 < 0)
return true;
int min = Math.Min(SelectionStart, Text.Length - 1);
int lastSpace = Text.LastIndexOf(' ', min, min);
if (lastSpace == -1) // we delete all except symbols after selection
{
Text = Text.Substring(SelectionStart);
return true;
}
string start = Text.Substring(0, lastSpace);
string end = Text.Substring(Math.Min(SelectionStart, Text.Length));
Text = start + end;
base.Select(lastSpace, 0);
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
示例3: ProcessCmdKey
// 입력(F12) 단축키 설정
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (!base.ProcessCmdKey(ref msg, keyData)) // 위에서 처리 안했으면
{
if (keyData.Equals(Keys.F12))
{
button1.PerformClick();
return true;
}
if (keyData.Equals(Keys.Escape))
{
button2.PerformClick();
return true;
}
if (keyData.Equals(Keys.F1))
{
button3.PerformClick();
return true;
}
if (keyData.Equals(Keys.F9))
{
button4.PerformClick();
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
示例4: IsInputKey
protected override bool IsInputKey(Keys keyData) {
if (keyData.Equals(Keys.Down) && showSplit) {
return true;
} else {
return base.IsInputKey(keyData);
}
}
示例5: IsAcceptedKey
/// <summary>
/// Determines whether [is accepted key] [the specified key].
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>If the key is accepted.</returns>
public bool IsAcceptedKey(Keys key)
{
foreach (var acceptedKey in this.acceptedKeys)
{
if (key.Equals(acceptedKey))
{
return true;
}
}
return false;
}
示例6: keyPress
/// <summary>
/// Upon keypress, all players connected to this stream will be notified that a key is pressed.
/// </summary>
public void keyPress(Keys key)
{
Command command = Command.Unknown;
if (key.Equals(SkillAKey))
{
command = Command.SkillAKeyDown;
Key_A = true;
}
else if (key.Equals(SkillBKey))
{
command = Command.SkillBKeyDown;
Key_B = true;
}
else if (key.Equals(SkillCKey))
{
command = Command.SkillCKeyDown;
Key_C = true;
}
else if (key.Equals(SkillDKey))
{
command = Command.SkillDKeyDown;
Key_D = true;
}
else if (key.Equals(MoveDownKey))
{
command = Command.MoveDownKeyDown;
Key_DOWN = true;
}
else if (key.Equals(MoveLeftKey))
{
command = Command.MoveLeftKeyDown;
Key_LEFT = true;
}
else if (key.Equals(MoveRightKey))
{
command = Command.MoveRightKeyDown;
Key_RIGHT = true;
}
else if (key.Equals(MoveUpKey))
{
command = Command.MoveUpKeyDown;
Key_UP = true;
}
foreach (Controller player in connectedPlayers)
{
player.command(command);
}
}
示例7: Kh_KeyUp
private void Kh_KeyUp(Keys key, bool Shift, bool Ctrl, bool Alt)
{
if (key.Equals(Keys.NumLock))
{
if(numLockState)
{
numpadGroup.Brush = new SolidColorBrush(Color.Black);
keyboard.Update();
}
else
{
numpadGroup.Brush = new SolidColorBrush(selectedColor);
keyboard.Update();
}
numLockState = !numLockState;
}
}
示例8: ProcessCmdKey
/**Author: NGUYEN TUAN
* add key press. when user press enter, automatically, user log in to system
*/
/// <summary>
/// Key events on form. when user press enter, automatically, user log in to system
/// </summary>
/// <param name="msg">Message</param>
/// <param name="keyData">Key data </param>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (this.passwordEd.Focused&&keyData.Equals(Keys.Enter))
{
try
{
isLoginOk = false;
if (DoLogin())
{
isLoginOk = true;
this.Close();
}
}
catch (Exception er)
{
this.ShowError(er);
common.system.ShowErrorMessage(Languages.Libs.GetString("systemError"));
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
示例9: Player
public Player(Game1 g, ContentManager cm, String name, Vector2 startLocation, Keys forwardKey, Color color, bool flip, int tWidth)
{
this.g = g;
this.cm = cm;
this.location = startLocation;
this.name = name;
this.flipHorizontal = flip;
this.color = color;
this.tWidth = tWidth;
hitBox = this.cm.Load<Texture2D>("Hitbox");
Stand = this.cm.Load<Texture2D>(this.name + "/Stand");
WalkForward = this.cm.Load<Texture2D>(this.name + "/WalkForward");
WalkBack = this.cm.Load<Texture2D>(this.name + "/WalkBack");
Crouch = this.cm.Load<Texture2D>(this.name + "/Crouch");
Jump = this.cm.Load<Texture2D>(this.name + "/Jump");
JumpBack = this.cm.Load<Texture2D>(this.name + "/JumpBack");
AtkZ = this.cm.Load<Texture2D>(this.name + "/AtkZ");
AtkX = this.cm.Load<Texture2D>(this.name + "/AtkX");
AtkC = this.cm.Load<Texture2D>(this.name + "/AtkC");
ArialZ = this.cm.Load<Texture2D>(this.name + "/ArialZ");
ArialX = this.cm.Load<Texture2D>(this.name + "/ArialX");
ArialC = this.cm.Load<Texture2D>(this.name + "/ArialC");
if (forwardKey.Equals(Keys.Right))
{
this.jumpKey = Keys.Up;
this.crouchKey = Keys.Down;
this.backKey = Keys.Left;
this.forwardKey = Keys.Right;
this.atk1Key = Keys.Z;
this.atk2Key = Keys.X;
this.atk3Key = Keys.C;
}
else if (forwardKey.Equals(Keys.D))
{
this.jumpKey = Keys.W;
this.crouchKey = Keys.S;
this.backKey = Keys.A;
this.forwardKey = Keys.D;
this.atk1Key = Keys.J;
this.atk2Key = Keys.K;
this.atk3Key = Keys.L;
}
}
示例10: Tir
// Quand le joueur appuye sur un des boutons pour tirer
public void Tir(Keys fire)
{
if (fire.Equals(Keys.Space) && alive) // on vérifie si le joueur est encore vivant et si il appuye sur la barre d'espace
{
Tir tir = new Tir(this); // On ajoute un nouvel objet de type tir
tirs.Add(tir); // on ajoute à la liste des tirs du joueur
if (totalPoint > 0) // on retranche a chaque tir un point de score (on ne descend pas en dessous de zéro)
{
totalPoint--;
}
}
if (fire.Equals(Keys.Enter) && alive && combo == 1000 && !destruction) // on vérifie si le joueur appuye sur enter, si il est vivant et si sa jauge est rempli pour pouvoir faire le super tir
{
combo = 0; // on remet la jauge a zéro
destruction = true; // on envoie au panel le fait que le joueur a déclanché son super tir
}
}
示例11: OnKeyPressed
protected override void OnKeyPressed(Keys keyData)
{
if (keyData.Equals(Keys.Escape))
{
FindReplace.CloseDialogIfNeeded();
}
}
示例12: isKeyToAutocomplete
private bool isKeyToAutocomplete(Keys key)
{
if (key.Equals(Keys.Enter) || key.Equals(Keys.Space) || key.Equals(Keys.Tab) || (key.Equals(Keys.OemPipe) && (Control.ModifierKeys == Keys.Shift)))
return true;
return false;
}
示例13: keyboard_KeyReleased
void keyboard_KeyReleased(Keys key)
{
//Quit game when escape is pressed
if (key.Equals(Keys.Escape))
game.Exit();
//stop scrolling if mouse is in the middle
MouseState ms = mouse.GetState();
if (key.Equals(Keys.Right) && !(ms.X > viewport.Width * 0.95))
baseGame.scrollRight = false;
if (key.Equals(Keys.Left) && !(ms.X < viewport.Width * 0.05))
baseGame.scrollLeft = false;
if (key.Equals(Keys.Up) && !(ms.Y < viewport.Height * 0.05))
baseGame.scrollUp = false;
if (key.Equals(Keys.Down) && !(ms.Y > viewport.Height * 0.95))
baseGame.scrollDown = false;
//
if (key.Equals(Keys.M))
{
if (baseGame.menuOpen)
{
baseGame.menuOpen = false;
gui.Screen = gameScreen;
}
else
{
enterMenu();
}
}
if (key.Equals(Keys.Space))
{
effects.addFloatingString("CAT!!",new Vector2(ms.X,ms.Y),Color.Red);
}
}
示例14: updateListBoxSelection
private void updateListBoxSelection(Keys key)
{
//handle key up on the listbox
if (key.Equals(Keys.Up))
{
if (this.listBox.SelectedIndex > 0)
{
listBox.SelectedIndex--;
}
else
listBox.SelectedIndex = 0;
}
//handle key down on the listbox
else if (key.Equals(Keys.Down))
{
if (this.listBox.SelectedIndex < this.listBox.Items.Count - 1)
this.listBox.SelectedIndex++;
}
if (!isUpOrDownKey(key))
{
string currentText = getTextToSelectListBox();
int matchingIndex = this.listBox.FindString(currentText);
if (currentText.Equals("") || matchingIndex == ListBox.NoMatches)
this.listBox.ClearSelected();
else
{
this.listBox.SelectedIndex = matchingIndex;
}
}
}
示例15: ProcessDialogKey
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData.Equals(Keys.Delete)) {
ArrayList itemsToRemove = new ArrayList(soundItems.Count);
this.Enabled = false;
propertyGrid.SelectedObject = null;
foreach (SoundItem sm in soundItems) {
if (sm.Selected) {
itemsToRemove.Add(sm);
}
}
foreach (SoundItem sm in itemsToRemove) {
soundItems.Remove(sm);
sm.Dispose();
}
this.Enabled = true;
this.Invalidate();
this.Update();
}
return base.ProcessDialogKey(keyData);
}