• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.KeysConverter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



KeysConverter类属于System.Windows.Forms命名空间,在下文中一共展示了KeysConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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


示例2: 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


示例3: USBScannerListener

 public USBScannerListener(Form form)
 {
     form.KeyUp += scannerKeyUp;
     this.words = new List<string>();
     this.currentWord = string.Empty;
     this.keyConverter = new KeysConverter();
 }
开发者ID:Rickedb,项目名称:USBScanner,代码行数:7,代码来源:USBScannerListener.cs


示例4: keyPress

        // I don't like that mouse buttons are handled here. This will be fixed later.
        public void keyPress(string rawKey, int hold = 0)
        {
            if (rawKey.Contains("M_"))
            {
                switch (rawKey)
                {
                    case ("M_1"):
                        Mouse.PressButton(Mouse.MouseKeys.Left);
                        break;
                    case ("M_2"):
                        Mouse.PressButton(Mouse.MouseKeys.Right);
                        break;
                    case ("M_3"):
                        Mouse.PressButton(Mouse.MouseKeys.Middle);
                        break;
                    default:
                        Console.WriteLine("Invalid Mouse Button Press");
                        break;

                }
            }
            else
            {
                KeysConverter kc = new KeysConverter();
                Keys key = (Keys)kc.ConvertFromString(rawKey);

                if (hold == 0)
                    Keyboard.KeyPress(key, 5);
                else if (hold == 1)
                    Keyboard.KeyDown(key);
                else
                    Keyboard.KeyUp(key);
            }
        }
开发者ID:j0z,项目名称:PlayM,代码行数:35,代码来源:InputSynth.cs


示例5: SendRequestInternal

        protected override void SendRequestInternal(string request)
        {
            string[] args = StringUtils.ToStringArray(request, ',');

            string keyCode = "", repeat = "", command = "", windowName = "", remoteName = "";

            int i = 0;
            if (args.Length > i)
                keyCode = args[i++];
            if (args.Length > i)
                repeat = args[i++];
            if (args.Length > i)
                command = args[i++];
            if (args.Length > i)
                windowName = args[i++];
            if (args.Length > i)
                remoteName = args[i++];

            IntPtr hWnd = User32.FindWindow(windowName, null);
            if (hWnd != IntPtr.Zero)
            {
                KeysConverter kc = new KeysConverter();
                Keys k = (Keys)kc.ConvertFromInvariantString(command);
                KeyEventArgs kea = new KeyEventArgs(k);

                // Key down
                int msg = (int)Messages.WM_KEYDOWN;
                User32.PostMessage(hWnd, msg, kea.KeyValue, 0);
            }
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:30,代码来源:HotkeyOutputPin.cs


示例6: set_hotkey

        public void set_hotkey(string hotkey_string)
        {
            var cvt = new KeysConverter();
            var key = (Keys)cvt.ConvertFrom(hotkey_string);

            ModifierKeys mk = SkipDonation.ModifierKeys.None;

            if (key.HasFlag(Keys.Control))
            {
                mk |= SkipDonation.ModifierKeys.Control;
                key = key & (~Keys.Control);
            }

            if (key.HasFlag(Keys.Alt))
            {
                mk |= SkipDonation.ModifierKeys.Alt;
                key = key & (~Keys.Alt);
            }

            if (key.HasFlag(Keys.Shift))
            {
                mk |= SkipDonation.ModifierKeys.Shift;
                key = key & (~Keys.Shift);
            }

            hook.RegisterHotKey(mk, key);
            lbl_hotkey.Text = hotkey_string;
        }
开发者ID:pajlada,项目名称:SkipDonation,代码行数:28,代码来源:MainForm.cs


示例7: textBox1_KeyDown

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys modifierKeys = e.Modifiers;

            Keys pressedKey = e.KeyData ^ modifierKeys; //remove modifier keys

            //do stuff with pressed and modifier keys
            var converter = new KeysConverter();
            //textBox1.Text = converter.ConvertToString(e.KeyData);
        }
开发者ID:riyadparvez,项目名称:prank-sharp,代码行数:10,代码来源:SettingsForm.cs


示例8: CanConvertTo

		public void CanConvertTo ()
		{
			KeysConverter c = new KeysConverter ();

			Assert.AreEqual (true, c.CanConvertTo (null, typeof (string)), "A1");
			Assert.AreEqual (false, c.CanConvertTo (null, typeof (int)), "A2");
			Assert.AreEqual (false, c.CanConvertTo (null, typeof (float)), "A3");
			Assert.AreEqual (false, c.CanConvertTo (null, typeof (object)), "A4");
			Assert.AreEqual (false, c.CanConvertTo (null, typeof (Enum)), "A5");
			Assert.AreEqual (true, c.CanConvertTo (null, typeof (Enum [])), "A6");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:KeysConverterTest.cs


示例9: 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


示例10: InitializeHotKeys

        private void InitializeHotKeys()
        {
            var kc = new SWF.KeysConverter();
            var mkc = new ModifierKeysConverter();

            _sshHotkey = new HotKey((ModifierKeys)mkc.ConvertFromString(_config.Hotkeys.Select.Modifiers), (SWF.Keys)kc.ConvertFromString(_config.Hotkeys.Select.Key));
            _sshHotkey.HotKeyPressed += k => ((MainWindow)this.MainWindow).ShowFullscreenWindow();

            Exit += (s, e) =>
            {
                _sshHotkey.Dispose();
            };
        }
开发者ID:zerkms,项目名称:shary,代码行数:13,代码来源:App.xaml.cs


示例11: ReadKey

 public Keys ReadKey(string section, string key, Keys defaultValue)
 {
     try
     {
         KeysConverter kc = new KeysConverter();
         Keys k = (Keys)kc.ConvertFromString(Read(section, key));
         return k;
     }
     catch (Exception e)
     {
         return defaultValue;
     }
 }
开发者ID:StrayDev,项目名称:Stray.Common,代码行数:13,代码来源:INIFile.cs


示例12: Main

        /// <summary>
        /// In the main method, we attempt to read all the information from the .ini file. To convert a string to a System.Windows.Forms.Keys, we use a KeyConverter.
        /// Do not forget to add a reference to System.Windows.Forms, which can be done via project> add reference> assemblies> framework.
        /// I also added using System.Windows.Keys; at the beginning of the project so we don't have to type that every time we use one of its methods.
        /// </summary>
        public static void Main()
        {
            //A keysconverter is used to convert a string to a key.
            KeysConverter kc = new KeysConverter();

            //We create two variables: one is a System.Windows.Keys, the other is a string.
            Keys myKeyBinding;
            string playerName;
            

            //Use a try/catch, because reading values from files is risky: we can never be sure what we're going to get and we don't want our plugin to crash.
            try
            {
                //We assign myKeyBinding the value of the string read by the method getMyKeyBinding(). We then use the kc.ConvertFromString method to convert this to a key.
                //If the string does not represent a valid key (see .ini file for a link) an exception is thrown. That's why we need a try/catch.
                myKeyBinding = (Keys)kc.ConvertFromString(getMyKeyBinding());

                //For the playerName, we don't need to convert the value to a Key, so we can simply assign playerName to the return value of getPlayerName(). 
                //Remember we've already made sure the name can't be longer than 12 characters.
                playerName = getPlayerName();
            }
            //If there was an error reading the values, we set them to their defaults. We also let the user know via a notification.
            catch
            {
                myKeyBinding = Keys.B;
                playerName = "DefaultName";
                Game.DisplayNotification("There was an error reading the .ini file. Setting defaults...");
            }

            //Now you can do whatever you like with them! To finish off the example, we create a notification with our name when we press our keybinding.

            //We create a new GameFiber to listen for our key input. 
            GameFiber.StartNew(delegate
            {
                //This loop runs until it's broken
                while (true)
                {
                    //If our key has been pressed
                    if (Game.IsKeyDown(myKeyBinding))
                    {
                        //Create a notification displaying our name.
                        Game.DisplayNotification("Your name is: " + playerName + ".");
                        //And break out of the loop.
                        break;
                    }

                    //Let other GameFibers do their job by sleeping this one for a bit.
                    GameFiber.Yield();
                }
            });
        }
开发者ID:alexguirre,项目名称:LSPDFR-API,代码行数:56,代码来源:EntryPoint.cs


示例13: SetDestPathWithOverwriteConfirm

 public void SetDestPathWithOverwriteConfirm(string path)
 {
     string keyStr = new KeysConverter().ConvertToString((this.LinkedKey & ~Keys.Shift));
     if ((this.LinkedKey & Keys.Shift) == Keys.Shift)
         keyStr = "Shift + " + keyStr;
     var dr = MessageBox.Show(
         "キー " + LinkedKey.ToString() + "にはすでに設定されているパスがあります。" + Environment.NewLine +
         "すでにこのキーへ振り分けた画像の振り分け先も変更しますか?" + Environment.NewLine +
         "(キャンセルを押すと上書きをしません)",
         "キー設定の上書き",
         MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
     if (dr == DialogResult.Cancel)
         return;
     else
         this.SetDestPath(path, dr == DialogResult.Yes);
 }
开发者ID:karno,项目名称:Typict,代码行数:16,代码来源:Destination.cs


示例14: SaveKeymapToSettings

        private void SaveKeymapToSettings()
        {
            KeysConverter keysConverter = new KeysConverter();

            Properties.CustomKeys.Default.BackUp = (Keys)keysConverter.ConvertFromString(comboBoxBackUp.SelectedItem.ToString());
            Properties.CustomKeys.Default.BackLeft = (Keys)keysConverter.ConvertFromString(comboBoxBackLeft.SelectedItem.ToString()) ;
            Properties.CustomKeys.Default.BackRight = (Keys)keysConverter.ConvertFromString(comboBoxBackRight.SelectedItem.ToString());

            Properties.CustomKeys.Default.MidUp = (Keys)keysConverter.ConvertFromString(comboBoxMidUp.SelectedItem.ToString());
            Properties.CustomKeys.Default.MidDown = (Keys)keysConverter.ConvertFromString(comboBoxMidDown.SelectedItem.ToString());
            Properties.CustomKeys.Default.MidLeft = (Keys)keysConverter.ConvertFromString(comboBoxMidLeft.SelectedItem.ToString());
            Properties.CustomKeys.Default.MidRight = (Keys)keysConverter.ConvertFromString(comboBoxMidRight.SelectedItem.ToString());

            Properties.CustomKeys.Default.Push = (Keys)keysConverter.ConvertFromString(comboBoxMidPush.SelectedItem.ToString());

            Properties.CustomKeys.Default.Save();
        }
开发者ID:Johnsel,项目名称:KinEmote,代码行数:17,代码来源:CustomKeySetup.cs


示例15: ShortCutDropDownLoop

 private void ShortCutDropDownLoop(ToolStripMenuItem ts)
 {
     for (int i = 0; i < ts.DropDownItems.Count; i++)
     {
         if ((ts.DropDownItems[i].Tag != null) && (ts.DropDownItems[i].Tag.ToString() != ""))
         {
             ToolStripMenuItem item = (ToolStripMenuItem) ts.DropDownItems[i];
             string text = this.ShortCutAdd(this.TagName(item.Tag.ToString()));
             KeysConverter converter = new KeysConverter();
             item.ShortcutKeys = (Keys) converter.ConvertFromInvariantString(text);
         }
         else if ((ts.DropDownItems[i].GetType() == typeof(ToolStripMenuItem)) && (((ToolStripMenuItem) ts.DropDownItems[i]).DropDownItems.Count > 0))
         {
             this.ShortCutDropDownLoop((ToolStripMenuItem) ts.DropDownItems[i]);
         }
     }
 }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:17,代码来源:UserKeySet.cs


示例16: 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


示例17: 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


示例18: Setup

        public static void Setup(String savePath)
        {
            keys = new Hashtable ();
            graphics = new Hashtable ();
            sound = new Hashtable ();
            game = new Hashtable ();

            kc = new KeysConverter ();

            settingsPath = savePath;

            if (!Directory.Exists (settingsPath))
            {
                Directory.CreateDirectory (settingsPath);
            }

            CheckForSettingsFiles ();
        }
开发者ID:tubitos,项目名称:1,代码行数:18,代码来源:Saver.cs


示例19: Parse

 public static HotKey Parse(string str)
 {
     HotKey hotKey = new HotKey();
     hotKey.Ctrl = str.Contains("Ctrl");
     hotKey.Alt = str.Contains("Alt");
     hotKey.Shift = str.Contains("Shift");
     hotKey.Win = str.Contains("Win");
     string[] definitions = str.Split('+');
     string key = definitions[definitions.Length - 1];
     KeysConverter converter = new KeysConverter();
     try
     {
         hotKey.Key = (Keys)converter.ConvertFromString(key);
     }
     catch
     { hotKey.Key = DefaultKey; }
     return hotKey;
 }
开发者ID:gayancc,项目名称:lazycure-code,代码行数:18,代码来源:HotKey.cs


示例20: Preferences

 public Preferences()
 {
     KeysConverter k = new KeysConverter();
     Properties.Settings s = Properties.Settings.Default;
     s.Reload();
     if (s.UID == 0)
     {
         //s.UID = new Random().Next(10000);
         //while (!uploader.InitializeUID(s.UID.ToString(), ""))
         //    s.UID = new Random().Next(10000);
         UID setID = new UID();
         if (setID.ShowDialog()==DialogResult.OK)
             s.UID = setID.ID;
     }
     _sc1 = (Keys)k.ConvertFromString(s.Shortcut_1);
     _sc2 = (Keys)k.ConvertFromString(s.Shortcut_2);
     _sc3 = (Keys)k.ConvertFromString(s.Shortcut_3);
 }
开发者ID:ajansen7,项目名称:Pointing-Magnifier,代码行数:18,代码来源:Preferences.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.Label类代码示例发布时间:2022-05-26
下一篇:
C# Forms.KeyPressEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap