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


C# KeysConverter.ConvertToString方法代码示例

本文整理汇总了C#中System.Windows.Forms.KeysConverter.ConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C# KeysConverter.ConvertToString方法的具体用法?C# KeysConverter.ConvertToString怎么用?C# KeysConverter.ConvertToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.KeysConverter的用法示例。


在下文中一共展示了KeysConverter.ConvertToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadKeyCode

        public static string ReadKeyCode(int vkCode)
        {
            var key = (Keys)vkCode;
            KeysConverter converter = new KeysConverter();
            return converter.ConvertToString(key);

            //char ch = ' ';

            //int virtualKey = KeyInterop.VirtualKeyFromKey(key);
            //byte[] keyboardState = new byte[256];
            //GetKeyboardState(keyboardState);

            //uint scanCode = MapVirtualKey((uint)virtualKey, MapType.MAPVK_VK_TO_VSC);
            //StringBuilder stringBuilder = new StringBuilder(2);

            //int result = ToUnicode((uint)virtualKey, scanCode, keyboardState, stringBuilder, stringBuilder.Capacity, 0);
            //switch (result)
            //{
            //    case -1:
            //        break;
            //    case 0:
            //        break;
            //    case 1:
            //        {
            //            ch = stringBuilder[0];
            //            break;
            //        }
            //    default:
            //        {
            //            ch = stringBuilder[0];
            //            break;
            //        }
            //}
            //return ch.ToString();
        }
开发者ID:borigas,项目名称:EventTracker,代码行数:35,代码来源:KeyHelpers.cs

示例2: fShortcut_KeyDown

        private void fShortcut_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Back)
            {
                Keys modifierKeys = e.Modifiers;
                Keys pressedKey = e.KeyData ^ modifierKeys; //remove modifier keys

                if (modifierKeys != Keys.None && pressedKey != Keys.None && pressedKey != Keys.Menu && pressedKey != Keys.ControlKey)
                {
                    //do stuff with pressed and modifier keys
                    var converter = new KeysConverter();
                    fShortcut.Text = converter.ConvertToString(e.KeyData);
                    //At this point, we know a one or more modifiers and another key were pressed
                    //modifierKeys contains the modifiers
                    //pressedKey contains the other pressed key
                    //mainform.UnregisterHooks();
                   // mainform.RegisterFileHook(modifierKeys, pressedKey);
                    Properties.Settings.Default.fShortcut = converter.ConvertToInvariantString(e.KeyData);
                }
            }
            else
            {
                e.Handled = false;
                e.SuppressKeyPress = true;

                fShortcut.Text = "";
            }
        }
开发者ID:WilHall,项目名称:synchy-win,代码行数:28,代码来源:Preferences.cs

示例3: listView1_KeyDown

        private void listView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                KeysConverter kc = new KeysConverter();

                ListViewItem lvi = listView1.Items[listView1.SelectedIndices[0]];
                lvi.SubItems[3].Text = kc.ConvertToString(e.KeyData);
                lvi.SubItems[3].Tag = e.KeyData;
                e.Handled = true;
            }
        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:12,代码来源:SettingsPanel.cs

示例4: SettingForm_Load

        private void SettingForm_Load(object sender, EventArgs e)
        {

            this.CenterToScreen();

            // value -> dialog
            cbAlt.Checked = Properties.Settings.Default.HotKeyAlt;
            cbCtrl.Checked = Properties.Settings.Default.HotKeyCtrl;
            cbShift.Checked = Properties.Settings.Default.HotKeyShift;
            cbWin.Checked = Properties.Settings.Default.HotKeyWin;
            KeysConverter kc = new KeysConverter();
            txtbxHotkey.Text = kc.ConvertToString(Properties.Settings.Default.HotKeyCode);
            txtbxHotkey.Tag = Properties.Settings.Default.HotKeyCode;

            tbStartWith.Text = new string((char)Properties.Settings.Default.ChrStartWith, 1);
            tbEndWith.Text = new string(new char[] { (char)Properties.Settings.Default.ChrEndWith });
            tbSkipMatching.Text = new string((char)Properties.Settings.Default.ChrSkipMatching, 1);
            tbEqual.Text = new string((char)Properties.Settings.Default.ChrEqual, 1);

            EnvManager em = EnvManager.getInstance();
            tbAnyFolder.Text = string.Join("\r\n", em.getAnyFolderList());


            // lsvUserItem.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            
            foreach (Item item in em.getUserItemList())
            {
                ListViewItem lvi = new ListViewItem(item.getItemName());
                lvi.Tag = item;
                lsvUserItem.Items.Add(lvi);
            }
            lsvUserItem.Columns[0].Width = lsvUserItem.ClientSize.Width;

            tbUpdateInterval.Text = Properties.Settings.Default.updateInterval.ToString();
            tbSearchHistoryMax.Text = Properties.Settings.Default.SearchHistoryMax.ToString();
            tbExecHistoryMax.Text = Properties.Settings.Default.ExecHistoryMax.ToString();
            tbDisplayItemMax.Text = Properties.Settings.Default.DisplayItemMax.ToString();

            fontDialog.Font = Properties.Settings.Default.Font;
            fontDialog.Color = Properties.Settings.Default.FontColor;
            colorDialogBCText.Color = Properties.Settings.Default.BackColorText;
            colorDialogBCForm.Color = Properties.Settings.Default.BackColorForm;
            tbFormOpacity.Text = Properties.Settings.Default.OpacityForm.ToString();

        }
开发者ID:Rab-Duck,项目名称:Mutter-Launcher.NET,代码行数:45,代码来源:SettingForm.cs

示例5: txtShortcutKeys_KeyDown

        private void txtShortcutKeys_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Back)
            {
                Keys modifierKeys = e.Modifiers;
                Keys pressedKey = e.KeyData ^ modifierKeys;

                if (modifierKeys != Keys.None && pressedKey != Keys.None)
                {
                    var converter = new KeysConverter();
                    txtShortcutKeys.Text = converter.ConvertToString(e.KeyData);
                }
                e.Handled = true;
            }
            else
            {
                e.Handled = false;
                e.SuppressKeyPress = true;

                txtShortcutKeys.Text = "";
            }
            
        }
开发者ID:tdhieu,项目名称:iSpy,代码行数:23,代码来源:AddRemoteCommand.cs

示例6: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            VolUpHotkey = Properties.Settings.Default.VolUpHotkey;
            VolUpModifier = Properties.Settings.Default.VolUpModifier;
            VolDownHotkey = Properties.Settings.Default.VolDownHotkey;
            VolDownModifier = Properties.Settings.Default.VolDownModifier;
            MuteHotkey = Properties.Settings.Default.MuteHotkey;
            MuteModifier = Properties.Settings.Default.MuteModifier;
            LastName = Properties.Settings.Default.LastName;
            VolumeSteps = Properties.Settings.Default.LastVolStep;

            if (LastName != String.Empty)
                CueTextBox_AppName.Text = LastName;

            if (VolumeSteps != 0)
                numericUpDown_VolumeSteps.Value = VolumeSteps;

            RegisterHotKey(this.Handle, 1, (int)VolUpModifier, (int)VolUpHotkey);
            RegisterHotKey(this.Handle, 2, (int)VolDownModifier, (int)VolDownHotkey);
            RegisterHotKey(this.Handle, 3, (int)MuteModifier, (int)MuteHotkey);

            var converter = new KeysConverter();

            if (VolUpModifier != Keys.None)
                textBox_VolUpHotkey.Text = converter.ConvertToString(VolUpModifier + " + " + VolUpHotkey);

            else if (VolUpModifier == Keys.None)
                textBox_VolUpHotkey.Text = converter.ConvertToString(VolUpHotkey);

            if (VolDownModifier != Keys.None)
                textBox_VolDownHotkey.Text = converter.ConvertToString(VolDownModifier + " + " + VolDownHotkey);

            else if (VolDownModifier == Keys.None)
                textBox_VolDownHotkey.Text = converter.ConvertToString(VolDownHotkey);

            if (MuteModifier != Keys.None)
                textBox_MuteHotkey.Text = converter.ConvertToString(MuteModifier + " + " + MuteHotkey);

            else if (MuteModifier == Keys.None)
                textBox_MuteHotkey.Text = converter.ConvertToString(MuteHotkey);

            VolumeSteps = decimal.ToInt32(numericUpDown_VolumeSteps.Value);
        }
开发者ID:razorlikes,项目名称:AppVolumeHotkeys,代码行数:45,代码来源:Form1.cs

示例7: OnEdit

        void OnEdit(object sender, DevExpress.XtraEditors.Controls.QueryProcessKeyEventArgs e)
        {
            DevExpress.XtraEditors.TextEdit te = (DevExpress.XtraEditors.TextEdit) sender;
            KeysConverter kc = new KeysConverter();
            string keyChar = kc.ConvertToString(null, System.Globalization.CultureInfo.CurrentCulture, e.KeyData);  //только англ символы. repositoryItemTextEdit не реагирует на ввод, костыль

            if(acceptableCellInput.Contains(keyChar))   //ограничить ввод
                te.EditValue = keyChar;
        }
开发者ID:EvilKot,项目名称:TimesheetTest,代码行数:9,代码来源:MainForm.cs

示例8: CreateMenuItem

		protected ToolStripItem CreateMenuItem(ChoiceBase choice, out bool reallyVisible)
		{
			UIItemDisplayProperties display = choice.GetDisplayProperties();
			reallyVisible = display.Visible;

			string label = display.Text;
			if (label == null)
				label = AdapterStrings.ErrorGeneratingLabel;

			label = label.Replace("_", "&");

			ToolStripMenuItem item = new ToolStripMenuItem(label);

			item.AccessibilityObject.Name = choice.Id;
			item.Tag = choice.Id;


			if (choice is CommandChoice)
			{
				item.Click += OnClick;
			}
			else
			{
				item.Click += choice.OnClick;
			}

			Image image = null;
			if (display.ImageLabel != "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			item.Image = image;
			item.Checked = display.Checked;

			if(choice.Shortcut != Keys.None)
			{
				KeysConverter sc = new KeysConverter();

				try
				{
					if (IsAcceptableShortcut(choice.Shortcut))
						item.ShortcutKeys = choice.Shortcut;
					// otherwise some other code must implement the shortcut, the built-in menu item code won't do it.
				}
				catch(Exception ex)
				{
					if (!(ex is InvalidEnumArgumentException))
						throw new ConfigurationException(
							"Software couldn't understand or doesn't support this shortcut: ("
							 + choice.Shortcut + ") for " + choice.Label, ex);
				}
			}

			Debug.Assert(item != null);
			item.Tag = choice;
			item.Enabled = display.Enabled;
			item.Visible = display.Visible;

			object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

			if (helper != null)
			{
				String s = ((IContextHelper)helper).GetToolTip(choice.HelpId);
				item.ToolTipText = s;
				if (choice.Shortcut != Keys.None)
				{

					KeysConverter kc = new KeysConverter();
					item.ToolTipText += '(' + kc.ConvertToString(choice.Shortcut) + ')';
				}

			}
			else
				item.ToolTipText = item.Text.Replace("&", ""); //useful for buttons.


			choice.ReferenceWidget = item;
			return item;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:77,代码来源:BarAdapterBase.cs

示例9: CreateButtonItem

		/// <summary>
		/// Create a button item for use on a menu or a toolbar.
		/// </summary>
		/// <param name="choice">The details for the new item.</param>
		/// <param name="reallyVisible">true if the item will be visible eventually
		/// (it never is right away, because the parent control isn't yet)</param>
		/// <exception cref="ConfigurationException"></exception>
		/// <returns>The new item.</returns>
		protected ToolStripItem CreateButtonItem(ChoiceBase choice, out bool reallyVisible)
		{
			UIItemDisplayProperties display = choice.GetDisplayProperties();
			reallyVisible = display.Visible;

			string label = display.Text;
			if (label == null)
				label = AdapterStrings.ErrorGeneratingLabel;

			label = label.Replace("_", "&");

			ToolStripButton  item = new ToolStripButton(label);

			item.AccessibilityObject.Name = choice.Id;
			item.Tag = choice.Id;


			if(choice is CommandChoice)
			{
				item.Click += OnClick;
			}
			else
			{
				item.Click += choice.OnClick;
			}

			Image image = null;
			if (display.ImageLabel!= "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			item.Image = image;
			item.Checked = display.Checked;

			Debug.Assert(item != null);
			item.Tag = choice;
			item.Enabled = display.Enabled;
			item.Visible = display.Visible;

			object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

			if (helper != null)
			{
				String s = ((IContextHelper)helper).GetToolTip(choice.HelpId);
				if (choice.Shortcut != Keys.None)
				{

					KeysConverter kc = new KeysConverter();
					s += '(' + kc.ConvertToString(choice.Shortcut) + ')';
					item.ToolTipText = s;
				}
			}
			else
				item.ToolTipText = item.Text.Replace("&",""); //useful for buttons.


			choice.ReferenceWidget = item;
			return item;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:65,代码来源:BarAdapterBase.cs

示例10: OnKeyDown

		protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
		{
            if (!execKeyDown)
            {
                e.Handled = true;
                base.OnKeyDown(e);
            }
            else
            {
                base.OnKeyDown(e);
                execMouseDown = false;
                execMouseLeave = false;
                execMouseUp = false;
                doubleClick = false;
                execKeyUp = true;

                System.Windows.Forms.ListViewItem item = null;

                if (this.SelectedItems.Count == 1)
                {
                    if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Home || e.KeyCode == Keys.End)
                    {
                        item = new ListViewItem();
                        switch (e.KeyCode)
                        {
                            case Keys.Up:
                                if (this.Items.IndexOf(this.SelectedItems[0]) > 0)
                                    item = this.Items[this.Items.IndexOf(this.SelectedItems[0]) - 1];
                                else
                                    item = this.Items[0];
                                break;
                            case Keys.Down:
                                if (this.Items.IndexOf(this.SelectedItems[0]) < this.Items.Count - 1)
                                    item = this.Items[this.Items.IndexOf(this.SelectedItems[0]) + 1];
                                else
                                    item = this.Items[this.Items.Count - 1];
                                break;
                            case Keys.Home:
                                item = this.Items[0];
                                break;
                            case Keys.End:
                                item = this.Items[this.Items.Count - 1];
                                break;
                        }

                        BeforeNewSelectionEventArgs args1 = new BeforeNewSelectionEventArgs(item, mSuccessfullSave);
                        this.OnBeforeNewSelection(args1);

                        mSuccessfullSave = args1.SelectionChange;

                        if (mSuccessfullSave)
                        {
                            item.Selected = true;
                            mLastItem = item;
                        }
                    }
                    else if (e.KeyCode == Keys.Alt || e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.ShiftKey)
                        execMouseDown = true; //permitir selecionar mais do que um elemento da lista usando ctrl/shift

                    else //if (!e.Alt && !e.Control && !e.Shift  && ((e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9) || (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9) || (e.KeyCode < Keys.Z || e.KeyCode > Keys.A)))
                    {
                        KeysConverter kc = new KeysConverter();
                        string keychar = kc.ConvertToString(e.KeyCode);

                        if (keychar.Contains("NumPad"))
                            keychar = keychar.Replace("NumPad", "");
                        if (keychar.Contains("OemMinus"))
                            keychar = keychar.Replace("OemMinus", "_");

                        int itemIndex = -1;
                        List<ListViewItem> matchItems = new List<ListViewItem>();
                        foreach (ListViewItem lvItem in this.Items)
                        {
                            if (lvItem.Text.ToLower().StartsWith(keychar.ToLower()))
                            {
                                matchItems.Add(lvItem);
                                if (this.SelectedItems.Count > 0 && this.SelectedItems[0] == lvItem)
                                    itemIndex = matchItems.Count - 1;
                            }
                        }

                        if (matchItems.Count == 1 && this.SelectedItems[0] != matchItems[0])
                            item = matchItems[0];
                        else if (matchItems.Count > 1)
                        {
                            if (itemIndex < 0)
                                item = matchItems[0];
                            else
                            {
                                if (itemIndex == matchItems.Count - 1)
                                    item = matchItems[0];
                                else
                                    item = matchItems[itemIndex + 1];
                            }
                        }

                        if (item != null)
                        {
                            BeforeNewSelectionEventArgs args1 = new BeforeNewSelectionEventArgs(item, mSuccessfullSave);
                            this.OnBeforeNewSelection(args1);
//.........这里部分代码省略.........
开发者ID:anvpires,项目名称:gisa,代码行数:101,代码来源:PxListView.cs

示例11: HandleKeyDown

        /// <summary>
        /// Switch to a window if user presses it's quick-key
        /// </summary>
        protected bool HandleKeyDown(Keys k)
        {
            if (!_showing) return false;

            if (k == Keys.Escape)
            {
                HideSwitcher();
                return true;
            }

            if (k == Keys.Tab)
            {
                TogglePopups();
                return true;
            }

            var converter = new KeysConverter();
            var ch = (converter.ConvertToString(k) ?? "").ToUpper();
            var idx = SelectorKeys.IndexOf(ch, StringComparison.Ordinal);
            if (idx < 0) return false;
            if (idx >= _windows.Count) return true;

            // Select and leave the switcher
            _windows[idx].Focus();
            HideSwitcher();
            return true;
        }
开发者ID:i-e-b,项目名称:WindowsJedi,代码行数:30,代码来源:SwitcherForm.cs

示例12: GetBehaviorByKeyStroke

 private Behavior GetBehaviorByKeyStroke(Keys keyCode)
 {
     KeysConverter kc = new KeysConverter();
     string keyChar = kc.ConvertToString(keyCode);
     keyChar = keyChar.Replace("NumPad", "");
     return _allowedBehaviors.Find((behavior) => behavior.KeyStroke == keyChar);
 }
开发者ID:kinoscope,项目名称:kinoscope,代码行数:7,代码来源:RunForm.cs

示例13: DecodePackages

        public static string DecodePackages(List<DataPackage> packages)
        {
            StringBuilder builder = new StringBuilder();
            foreach (DataPackage package in packages.OrderBy(p=>p.Time))
            {
                package.Keys.ForEach(key =>
                {
                    KeysConverter converter = new KeysConverter();
                    builder.Append(converter.ConvertToString(key));
                });
            }

            return builder.ToString();
        }
开发者ID:maxus0089,项目名称:MSpy,代码行数:14,代码来源:NetworkService.cs

示例14: GetShortcutDisplayString

		internal string GetShortcutDisplayString ()
		{
			if (this.show_shortcut_keys == false)
				return string.Empty;
			if (this.Parent == null || !(this.Parent is ToolStripDropDownMenu))
				return string.Empty;
				
			string key_string = string.Empty;

			if (!string.IsNullOrEmpty (this.shortcut_display_string))
				key_string = this.shortcut_display_string;
			else if (this.shortcut_keys != Keys.None) {
				KeysConverter kc = new KeysConverter ();
				key_string = kc.ConvertToString (this.shortcut_keys);
			}
			
			return key_string;
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:18,代码来源:ToolStripMenuItem.cs

示例15: textBox1_KeyDown

 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
         e.SuppressKeyPress = false;
     else
     {
         e.SuppressKeyPress = true;
         try
         {
             KeysConverter kc = new KeysConverter();
             string s = kc.ConvertToString(e.KeyCode).Replace("NumPad", "");
             if ((sender.Cast<TextBox>().Text + s).IsInt())
                 sender.Cast<TextBox>().SelectedText = s;
         }
         catch (Exception ex)
         {
             sender.Cast<TextBox>().Text = "";
         }
     }
 }
开发者ID:Rarder44,项目名称:SudokuSolver,代码行数:20,代码来源:FormSudoku.cs


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