本文整理汇总了C#中Key.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Key.ToString方法的具体用法?C# Key.ToString怎么用?C# Key.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Key
的用法示例。
在下文中一共展示了Key.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToCharacter
public static string ToCharacter(Key key)
{
string result = string.Empty;
string keyString = key.ToString();
if (keyString.Length == 1)
{
result = key.ToString();
}
if (keyString.Length == 2)
{
if(keyString.StartsWith("D"))
{
result = keyString.Substring(1,1);
}
}
if (keyString == "OemMinus")
{
result = "-";
}
if (keyString.Length == 7)
{
if (keyString.StartsWith("NumPad"))
{
result = keyString.Substring(6, 1);
}
}
return result;
}
示例2: setValue
public static void setValue(Key key, object value)
{
if (HttpContext.Current != null)
HttpContext.Current.Items[key.ToString()] = value;
else
CallContext.SetData(key.ToString(), value);
}
示例3: KeyLookup
public KeyLookup(Key key)
{
Value = key;
Description = key >= Key.D0 && key <= Key.D9 ? key.ToString().Substring(1)
: key == Key.OpenBrackets ? "Open Brackets"
: key == Key.CloseBrackets ? "Close Brackets"
: key == Key.EqualsPlus ? "Equals Plus"
: key.ToString();
}
示例4: EnsureIsStarted
public static void EnsureIsStarted(Key key,
ICacheItemRecalculationStrategy recalculationStrategy,
MethodInterceptionArgs args,
ICache cache)
{
var keyString = key.ToString();
Ensure.That<NHelpfulException.FrameworkExceptions.ArgumentException>(keyString.Length.IsLessThanOrEqualTo(260),
"key must be less than 260 characters long.");
try
{
bool createdNew;
var mutex = new Mutex(false, MutexPrefix + keyString, out createdNew);
if (createdNew)
{
if (cache[keyString].IsNotNull())
return;
//item already in cache, assume thread already started TODO: possibly log this as an error
ThreadPool.QueueUserWorkItem(
o => recalculationStrategy.RunRoutine(key, args, cache, mutex, args.Proceed));
//NOTE: mutex.ReleaseMutex(); is not called because the mutex is only expected to be released upon closure of the application
}
}
catch (Exception)
{
//log exception
throw;
}
}
示例5: SaveKeys
public void SaveKeys(ModifierKeys[] modifiers, Key key, ref String to)
{
String s = "";
modifiers.ToList().ForEach(k => s += k.ToString() + "+");
s += key.ToString();
to = s;
}
示例6: getAction
/// <summary>
/// <returns>Action desciptor for the given input key or None if not assigned
public String getAction(Key k)
{
String ks = k.ToString();
if (keyActions.Keys.Contains(ks))
return keyActions[ks];
else
return "None";
}
示例7: InternalKeyDown
public override void InternalKeyDown(Key key)
{
switch (key)
{
case Key.Space:
if (Text.Length + 1 <= CharacterLimit)
this.Text += " ";
break;
case Key.Back:
if (this.Text.Length < 1)
break;
this.Text = this.Text.Remove(this.Text.Length - 1);
break;
case Key.KeypadMinus:
case Key.Minus:
this.Text += "-";
break;
}
if (string.Compare(key.ToString().Remove(key.ToString().Length - 1), "Number") == 0)
{
if (Text.Length + 1 <= CharacterLimit)
this.Text += key.ToString()[key.ToString().Length - 1];
return;
}
if (key.ToString().Length > 1)
return;
bool capitalLetters = Parent.Keyboard[Key.LShift] || Parent.Keyboard[Key.RShift];
if (Text.Length + 1 <= CharacterLimit)
this.Text += capitalLetters ? key.ToString() : key.ToString().ToLower();
}
示例8: Translate
public static DInput.Key Translate(Key key)
{
if (KeyMap.ContainsKey(key))
return KeyMap[key];
DInput.Key dinputKey;
string keyName = key.ToString().Replace("Cursor", "").Replace("NumPad", "NumberPad");
return Enum.TryParse(keyName, out dinputKey) ? dinputKey : DInput.Key.Unknown;
}
示例9: HandleInputForKey
private static string HandleInputForKey(string inputText, Key key)
{
if (key >= Key.D0 && key <= Key.D9)
return inputText + key.ToString()[1].ToString(CultureInfo.InvariantCulture);
if (key >= Key.NumPad0 && key <= Key.NumPad9)
return inputText + key.ToString()[6].ToString(CultureInfo.InvariantCulture);
if (key >= Key.A && key <= Key.Z)
return inputText + key;
if (key == Key.Space)
return inputText + " ";
if (key == Key.Decimal || key == Key.Period)
return inputText + ".";
if (key == Key.Comma)
return inputText + ",";
if (key == Key.Backspace && inputText.Length > 0)
return inputText.Substring(0, inputText.Length - 1);
return inputText;
}
示例10: KeyParseWorksOnBothTypeOfEncryptedKey
public void KeyParseWorksOnBothTypeOfEncryptedKey()
{
var encryptedkey = new Key().GetEncryptedBitcoinSecret("abc", Network.Main);
Key.Parse(encryptedkey.ToString(), "abc", Network.Main);
var code = new BitcoinPassphraseCode("abc", Network.Main, null);
var encryptedkey2 = code.GenerateEncryptedSecret().EncryptedKey;
Key.Parse(encryptedkey2.ToString(), "abc", Network.Main);
}
示例11: Run
private void Run(Key key)
{
var keyStr = key.ToString();
int num;
if (keyStr[0] == 'F' && int.TryParse(keyStr.Replace("F", ""), NumberStyles.Number, CultureInfo.InvariantCulture, out num))
{
cItems.Run(num);
Close();
}
}
示例12: AssignKey
private void AssignKey(TextBox textBox, Key key)
{
if (textBox.Text == key.ToString())
return;
if (_viewModel.State.Shortcuts.Contains(key))
{
var response = MessageBox.Show(
string.Format("The key '{0}' is already assigned to another shortcut.\n Please select any other key.", key),
"Duplicated key",
MessageBoxButton.OKCancel,
MessageBoxImage.Warning);
if (response == MessageBoxResult.OK)
SelectKey(textBox);
}
else
{
textBox.Text = key.ToString();
}
}
示例13: should_generate_key
public void should_generate_key()
{
var key = new Key(512);
Console.WriteLine(key.ToString());
string pem = key.ToPem();
Console.WriteLine(pem);
Console.WriteLine(new Key(pem).ToString());
}
示例14: should_generate_key_and_public_counterpart
public void should_generate_key_and_public_counterpart()
{
var key = new Key(512).PublicKey;
Console.WriteLine(key.ToString());
string pem = key.ToPem();
Console.WriteLine(pem);
Console.WriteLine(new PublicKey(pem).ToString());
}
示例15: HandleInputForKey
private string HandleInputForKey(string inputText, Key key)
{
if (key >= Key.D0 && key <= Key.D9)
return inputText + key.ToString()[1].ToString(CultureInfo.InvariantCulture);
if (key >= Key.NumPad0 && key <= Key.NumPad9)
return inputText + key.ToString()[6].ToString(CultureInfo.InvariantCulture);
if (key >= Key.A && key <= Key.Z)
if (KeyNeedsToBeCapitalized())
return inputText + key;
else
return inputText + (char)((int)key + 32);
if (key == Key.Space)
return inputText + " ";
if (key == Key.Decimal || key == Key.Period)
return inputText + ".";
if (key == Key.Comma)
return inputText + ",";
if (key == Key.Backspace && inputText.Length > 0)
return inputText.Substring(0, inputText.Length - 1);
return inputText;
}