本文整理汇总了C#中Keys.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Keys.GetHashCode方法的具体用法?C# Keys.GetHashCode怎么用?C# Keys.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keys
的用法示例。
在下文中一共展示了Keys.GetHashCode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterHotKey
public void RegisterHotKey(Keys key, params KeyModifier[] modifiers)
{
var modifierBitmask = modifiers.Aggregate(0, (current, mod) => current | (int) mod);
WinApi.RegisterHotKey(_handle, _hotkeyIdx, modifierBitmask, key.GetHashCode());
_hotkeyIdx++;
}
示例2: TryConvertKey
private static bool TryConvertKey(Keys keyPressed, out char key)
{
bool shift = Keys.LeftShift.IsHeldDown () || Keys.RightShift.IsHeldDown ();
char c = (char)keyPressed.GetHashCode ();
if (c >= 'A' && c <= 'Z') {
if (shift) {
key = char.ToUpper (c);
}
else {
key = char.ToLower (c);
}
return true;
}
switch (keyPressed) {
//Decimal keys
case Keys.D0:
if (shift) {
key = ')';
}
else {
key = '0';
}
return true;
case Keys.D1:
if (shift) {
key = '!';
}
else {
key = '1';
}
return true;
case Keys.D2:
if (shift) {
key = '@';
}
else {
key = '2';
}
return true;
case Keys.D3:
if (shift) {
key = '#';
}
else {
key = '3';
}
return true;
case Keys.D4:
if (shift) {
key = '$';
}
else {
key = '4';
}
return true;
case Keys.D5:
if (shift) {
key = '%';
}
else {
key = '5';
}
return true;
case Keys.D6:
if (shift) {
key = '^';
}
else {
key = '6';
}
return true;
case Keys.D7:
if (shift) {
key = '&';
}
else {
key = '7';
}
return true;
case Keys.D8:
if (shift) {
key = '*';
}
else {
key = '8';
}
return true;
case Keys.D9:
if (shift) {
key = '(';
}
else {
key = '9';
}
return true;
//Decimal numpad keys
case Keys.NumPad0:
//.........这里部分代码省略.........
示例3: KeyToString
public String KeyToString(Keys k)
{
int khc = k.GetHashCode();
#region A-Z
//a-z,A-Z
if (khc >= Keys.A.GetHashCode() && khc <= Keys.Z.GetHashCode())
return ((char)k).ToString();
#endregion
#region D Keys
//`
if (k == Keys.OemTilde)
return "`";
//D0-D9
if (khc >= Keys.D0.GetHashCode() && khc <= Keys.D9.GetHashCode())
return ((char)k).ToString();
//-
if (k == Keys.OemMinus)
return "-";
//+
if (k == Keys.OemPlus)
return "=";
#endregion
#region NumKeys
//N0-N9 w/ numlock
if (InputEngine.NumLock && khc >= Keys.NumPad0.GetHashCode() && khc <= Keys.NumPad9.GetHashCode())
return "N" + k.ToString().Substring(k.ToString().Length - 1);
//N/
if (k == Keys.Divide)
return "/";
//N*
if (k == Keys.Multiply)
return "*";
//N-
if (k == Keys.Subtract)
return "-";
//N+
if (k == Keys.Add)
return "+";
//N.
if (k == Keys.Decimal)
return ".";
#endregion
#region OEM
// \
if (k == Keys.OemPipe)
return "\\";
//[
if (k == Keys.OemOpenBrackets)
return "[";
//]
if (k == Keys.OemCloseBrackets)
return "]";
//;
if (k == Keys.OemSemicolon)
return ";";
//'
if (k == Keys.OemQuotes)
return "'";
//,
if (k == Keys.OemComma)
return ",";
//.
if (k == Keys.OemPeriod)
return ".";
//?
if (k == Keys.OemQuestion)
return "/";
#endregion
return k.ToString();
}
示例4: benutzereingabe
public void benutzereingabe()
{
if (Keyboard.GetState().IsKeyUp(lastKey))
{
lastKey = Keys.None;
}
if (Keyboard.GetState().GetPressedKeys().Length > 0 && lastKey == Keys.None)
{
lastKey = Keyboard.GetState().GetPressedKeys()[0];
if (lastKey == Keys.Back)
{
if (InputText.Length != 0)
InputText = InputText.Substring(0, InputText.Length - 1);
}
else if (InputText.Length < 25)
{
if (lastKey.GetHashCode() == 13)
{
//isbenutzereingabe = false;
}
else
{
InputText += (char)lastKey.GetHashCode();
}
}
}
}
示例5: FormMain
//.........这里部分代码省略.........
{
Path = combinedLegacyPath,
NotifyFilter = NotifyFilters.LastWrite,
Filter = "SavedGame.asset",
IncludeSubdirectories = true,
EnableRaisingEvents = false
};
fswLegacy.Changed += FileWatcherTrigger;
}
RegistryKey regKey = Registry.CurrentUser;
regKey = regKey.OpenSubKey(@"Software\Valve\Steam");
if (regKey != null)
{
string steamPath = regKey.GetValue("SteamPath").ToString();
string combinedSteamPath = CombinePaths(steamPath, configCloudSavePath);
if (Directory.Exists(combinedSteamPath))
{
fswCloud = new FileSystemWatcher
{
Path = combinedSteamPath,
NotifyFilter = NotifyFilters.LastWrite,
Filter = "SavedGame.asset",
IncludeSubdirectories = true,
EnableRaisingEvents = false
};
fswCloud.Changed += FileWatcherTrigger;
}
}
ListOfSplitLists = new List<SplitList>();
ListOfResetEvents = new List<string>();
// If the app config has issues, report them.
if (configLegacySavePath == "")
{
buttonStopStart.Enabled = false;
MessageBox.Show("LegacySavePath is missing from app config.");
}
else if (configSplitHotkey == "")
{
buttonStopStart.Enabled = false;
MessageBox.Show("SplitHotkey is missing from app config.");
}
else if (configMapHotkey == "")
{
buttonStopStart.Enabled = false;
MessageBox.Show("mapHotkey is missing from app config.");
}
else if (configSplitList == "")
{
buttonStopStart.Enabled = false;
MessageBox.Show("SplitList is missing from app config.");
}
else
{
// Set up the config window
List<string> configSplitListLines = configSplitList.Split('[').Select(s => s.Trim()).ToList();
foreach (string splitListLine in configSplitListLines.Where(s => s.Length > 0))
{
ListOfSplitLists.Add(new SplitList
{
Name = splitListLine.Substring(0, splitListLine.IndexOf(']')),
Splits = splitListLine.Substring(splitListLine.IndexOf(']') + 1).Split(',').Select(a => a.Trim()).ToArray()
});
}
ListOfResetEvents = configResetEvents.Split(',').Select(s => s.Trim()).ToList();
splitCounter = 0;
scrollCounter = 0;
if (!Int32.TryParse(configSelectedSplitsIndex, out selectedSplitsIndex))
selectedSplitsIndex = 0;
checkBoxGlove.Checked = configItemAnimationSkipGlove == "true";
checkBoxBoots.Checked = configItemAnimationSkipBoots == "true";
checkBoxCloak.Checked = configItemAnimationSkipCloak == "true";
checkBoxStaff.Checked = configItemAnimationSkipStaff == "true";
previousText = "";
groupUrn.Visible = false;
ControlsDelegate.SetText(this, buttonStopStart, "Start Watching");
LoadSplits();
}
}
catch (Exception e)
{
MessageBox.Show(String.Format("{0}: {1}", e.GetType(), e.Message), "TeslaSplit - App Config Exception");
Application.Exit();
}
// Global Input Hook for EndeEvent
int id = 0; // The id of the hotkey.
RegisterHotKey(this.Handle, id, (int)KeyModifier.None, configEbhHotkey.GetHashCode());
}
示例6: UpdateScore
// ***********************************************************************
private void UpdateScore()
{
// Text eingabe verwalten
if (Keyboard.GetState().IsKeyUp(lastKey))
{
lastKey = Keys.None;
}
if (Keyboard.GetState().GetPressedKeys().Length > 0 && lastKey == Keys.None)
{
lastKey = Keyboard.GetState().GetPressedKeys()[0];
if (lastKey == Keys.Back)
{
if (_inputText.Length != 0)
_inputText = _inputText.Substring(0, _inputText.Length - 1);
}
else if (_inputText.Length < 16)
{
char input = (char)lastKey.GetHashCode();
if (char.IsLetterOrDigit(input) || input == ' ')
_inputText += (char)lastKey.GetHashCode();
}
if (lastKey == Keys.Enter)
{
// Highscore eintragen
Score newScore = new Score();
newScore.Name = _inputText;
newScore.Points = _gameState.GameStatistic.Highscore;
newScore.Round = _gameState.GameStatistic.Round;
HighscoreHelper.Add(newScore);
// Zu Highscore wechseln
_updateDelegate = UpdateHighscore;
_drawDelegate = DrawHighscore;
}
}
}
示例7: initlializeSettings
void initlializeSettings()
{
statisticAverange = new Averange(621);
averangeCheckBox.Enabled = false;
volumeAsOverlayCheckBox.Enabled = false;
intervalLabel.Enabled = false;
intervalTextBox.Enabled = false;
// progressBar1.Enabled = false;
volumeLabel.Enabled = false;
opacityLabel.Enabled = false;
opacityTrackBar.Enabled = false;
deviceIsSelected = false;
blackLabel.Enabled = false;
redLabel.Enabled = false;
colorLabel.Enabled = false;
label10.Enabled = false;
overlayKeyLabel.Enabled = false;
warningCheckBox.Enabled = false;
warningVolumeDb.Enabled = false;
warningVolumeLabel.Enabled = false;
warningVolumeTrackBar.Enabled = false;
redLabel.ForeColor = Color.Gray;
blackLabel.ForeColor = Color.Black;
try
{
using (StreamReader sr = new StreamReader("settings.txt"))
{
maxOutputVoltage = Convert.ToDouble(sr.ReadLine());
maxVoltageText.Text = maxOutputVoltage.ToString();
sensitivity = Convert.ToDouble(sr.ReadLine());
sensitivityText.Text = sensitivity.ToString();
impedance = Convert.ToDouble(sr.ReadLine());
impemendanceText.Text = impedance.ToString();
hotKey = Convert.ToBoolean(sr.ReadLine());
if (hotKey)
{
overlayKeyLabel.Checked = true;
ShiftLabel.Enabled = true;
label3.Enabled = true;
hotkeyChange.Enabled = true;
hotKeyNotify.Visible = true;
hotKey = true;
}
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Keys));
key = (Keys)converter.ConvertFromString(sr.ReadLine());
hotkeyChange.Text = key.ToString();
RegisterHotKey(this.Handle, 0, (int)KeyModifier.Shift, key.GetHashCode());
usbHeadphones = Convert.ToBoolean(sr.ReadLine());
if (!usbHeadphones)
{
usb.Checked = false;
usbHeadphones = false;
}
currentVolumeIsEnabled = Convert.ToBoolean(sr.ReadLine());
if (currentVolumeIsEnabled)
{
// currentVolume.Checked = true;
// maxVolumeRadioButton.Checked = false;
currentVolume.Image = radioButoonEnabled;
maxVolume.Image = radioButoonDisbaled;
}
else
{
// maxVolumeRadioButton.Checked = true;
maxVolume.Image = radioButoonEnabled;
currentVolume.Image = radioButoonDisbaled;
// currentVolume.Checked = false;
}
faintStatistics = Convert.ToDouble(sr.ReadLine());
moderateStatistics = Convert.ToDouble(sr.ReadLine());
veryLoudStatistics = Convert.ToDouble(sr.ReadLine());
weeklyFaint = Convert.ToInt32(sr.ReadLine());
weeklyModerate = Convert.ToInt32(sr.ReadLine());
weeklyVeryLoud = Convert.ToInt32(sr.ReadLine());
days[0] = Convert.ToInt32(sr.ReadLine());
days[1] = Convert.ToInt32(sr.ReadLine());
days[2] = Convert.ToInt32(sr.ReadLine());
days[3] = Convert.ToInt32(sr.ReadLine());
days[4] = Convert.ToInt32(sr.ReadLine());
days[5] = Convert.ToInt32(sr.ReadLine());
days[6] = Convert.ToInt32(sr.ReadLine());
lastDay = Convert.ToInt32(sr.ReadLine());
maxAverangeVolume = Convert.ToInt32(sr.ReadLine());
maxCurrentVolume = Convert.ToInt32(sr.ReadLine());
resetWeekly = Convert.ToBoolean(sr.ReadLine());
dangerStatistics = Convert.ToDouble(sr.ReadLine());
weeklyDanger = Convert.ToInt32(sr.ReadLine());
double sum = faintStatistics + moderateStatistics + veryLoudStatistics + dangerStatistics;
if (sum == 0)
{
sum = 1;
//.........这里部分代码省略.........
示例8: Update
public override void Update()
{
if (NameIsActive)
{
if (Keyboard.GetState().IsKeyUp(lastKey))
{
lastKey = Keys.None;
}
if (Keyboard.GetState().GetPressedKeys().Length > 0 && lastKey == Keys.None)
{
nameButton.Text = "";
lastKey = Keyboard.GetState().GetPressedKeys()[0];
if (lastKey == Keys.Back)
{
if (InputText.Length != 0)
InputText = InputText.Substring(0, InputText.Length - 1);
}
else if (InputText.Length < 25)
{
InputText += (char) lastKey.GetHashCode();
}
}
nameButton.Text = InputText;
nameButton.BackgroundTextur = nameButtonActiveTextur;
}
else
{
nameButton.BackgroundTextur = nameButtonTextur;
}
if (Hauptteil != null && Visier != null && Antrieb != null && Stabilisator != null && IsEnoughLiquid())
{
okButton.IsEnabled = true;
}
else
{
okButton.IsEnabled = false;
}
if (Mouse.GetState().LeftButton == ButtonState.Pressed && oldMouseState.LeftButton != ButtonState.Pressed)
{
NameIsActive = false;
}
oldMouseState = Mouse.GetState();
base.Update();
}
示例9: RegisterHotkey
/// <summary>
/// Register hotkey.
/// </summary>
/// <param name="key">The key to register as hotkey.</param>
/// <param name="modifier">The modifier for the hotkey.</param>
/// <param name="modifier2">The second modifier for the hotkey.</param>
public void RegisterHotkey(Keys key, HotkeyModifiersKeys modifier, HotkeyModifiersKeys modifier2)
{
if (!NativeMethods.RegisterHotKey(this.windowHandle.Handle, hotkeyId, (int)modifier | (int)modifier2, key.GetHashCode()))
throw new InvalidOperationException("Could not register hotkey. Error code: " + NativeMethods.GetLastError());
registeredHotkeys.Add(hotkeyId, new HotkeyInfo(key, modifier, modifier2));
hotkeyId++;
}
示例10: GetStringForKey
private String GetStringForKey(Keys k)
{
bool ShouldShift = InputEngine.Shift ^ InputEngine.CapsLock;
int khc = k.GetHashCode();
#region A-Z
//a-z,A-Z
if (khc >= Keys.A.GetHashCode() && khc <= Keys.Z.GetHashCode())
return ShouldShift ? ((char)k).ToString() : ((char)k).ToString().ToLower();
#endregion
#region D Keys
//`
if (k == Keys.OemTilde)
return ShouldShift ? "~" : "`";
//D0-D9
if (khc >= Keys.D0.GetHashCode() && khc <= Keys.D9.GetHashCode())
if (InputEngine.Shift)
{
if (k == Keys.D0)
return ")";
if (k == Keys.D1)
return "!";
if (k == Keys.D2)
return "@";
if (k == Keys.D3)
return "#";
if (k == Keys.D4)
return "$";
if (k == Keys.D5)
return "%";
if (k == Keys.D6)
return "^";
if (k == Keys.D7)
return "&";
if (k == Keys.D8)
return "*";
if (k == Keys.D9)
return "(";
}
else
return ((char)k).ToString();
//-
if (k == Keys.OemMinus)
return ShouldShift ? "_" : "-";
//+
if (k == Keys.OemPlus)
return ShouldShift ? "+" : "=";
#endregion
#region NumKeys
//N0-N9 w/ numlock
if (InputEngine.NumLock && khc >= Keys.NumPad0.GetHashCode() && khc <= Keys.NumPad9.GetHashCode())
return k.ToString().Substring(k.ToString().Length - 1);
//N/
if (k == Keys.Divide)
return "/";
//N*
if (k == Keys.Multiply)
return "*";
//N-
if (k == Keys.Subtract)
return "-";
//N+
if (k == Keys.Add)
return "+";
//N.
if (!ShouldShift && k == Keys.Decimal)
return ".";
#endregion
#region OEM
// \
if (k == Keys.OemPipe)
return ShouldShift ? "|" : "\\";
//[
if (k == Keys.OemOpenBrackets)
return ShouldShift ? "{" : "[";
//]
if (k == Keys.OemCloseBrackets)
return ShouldShift ? "}" : "]";
//;
if (k == Keys.OemSemicolon)
return ShouldShift ? ":" : ";";
//'
if (k == Keys.OemQuotes)
return ShouldShift ? "\"" : "'";
//,
if (k == Keys.OemComma)
return ShouldShift ? "<" : ",";
//.
if (k == Keys.OemPeriod)
return ShouldShift ? ">" : ".";
//?
if (k == Keys.OemQuestion)
return ShouldShift ? "?" : "/";
#endregion
#region Enter
if (k == Keys.Enter)
//.........这里部分代码省略.........
示例11: RegisterCurrentBattleHotkey
public void RegisterCurrentBattleHotkey(Keys hotkey, Keys modifiers)
{
if (this.InvokeRequired)
{
Invoke(new MethodInvoker(delegate () { RegisterCurrentBattleHotkey(hotkey, modifiers); }));
}
else
{
int modifiersValue = 0;
if (modifiers.HasFlag(Keys.Control))
modifiersValue += (int)KeyModifier.Control;
if (modifiers.HasFlag(Keys.Shift))
modifiersValue += (int)KeyModifier.Shift;
if (modifiers.HasFlag(Keys.Alt))
modifiersValue += (int)KeyModifier.Alt;
if (modifiers.HasFlag(Keys.LWin) || modifiers.HasFlag(Keys.RWin))
modifiersValue += (int)KeyModifier.WinKey;
if (hotkey != Keys.None && modifiers != Keys.None)
RegisterHotKey(this.Handle, 0, (int)modifiersValue, hotkey.GetHashCode());
}
}