当前位置: 首页>>代码示例>>C#>>正文


C# Key.ToString方法代码示例

本文整理汇总了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;
        }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:32,代码来源:KeyConverter.cs

示例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);
 }
开发者ID:bjornebjornson,项目名称:GemaAjaxSpike,代码行数:7,代码来源:ContextCache.cs

示例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();
 }
开发者ID:NicholasBuse,项目名称:codealignment,代码行数:9,代码来源:KeyLookup.cs

示例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;
            }
        }
开发者ID:benaston,项目名称:NCacheFacade,代码行数:31,代码来源:AsyncCacheItemRecalculator.cs

示例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;
 }
开发者ID:ondryaso,项目名称:j2-client,代码行数:7,代码来源:SettingsKeyInterpreter.cs

示例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";
 }
开发者ID:pyblendnet-js,项目名称:podplayer,代码行数:10,代码来源:KeyAction.cs

示例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();
            }
开发者ID:overdrivek,项目名称:severed-infinity,代码行数:32,代码来源:TextBox.cs

示例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;
		}
开发者ID:BEEden,项目名称:DeltaEngine.SharpDX,代码行数:9,代码来源:KeyboardKeyMapper.cs

示例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;
 }
开发者ID:remy22,项目名称:DeltaEngine,代码行数:18,代码来源:Keyboard.cs

示例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);
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:9,代码来源:BIP38Tests.cs

示例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();
     }
 }
开发者ID:noant,项目名称:Pyrite,代码行数:10,代码来源:WFast.xaml.cs

示例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();
            }
        }
开发者ID:Inner-room,项目名称:VrPlayer,代码行数:20,代码来源:ShortcutsSettings.xaml.cs

示例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());
        }
开发者ID:bitdiff,项目名称:secular,代码行数:11,代码来源:KeyTests.cs

示例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());
        }
开发者ID:bitdiff,项目名称:secular,代码行数:11,代码来源:KeyTests.cs

示例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;
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:21,代码来源:Keyboard.cs


注:本文中的Key.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。