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


C# KeysConverter.ConvertToInvariantString方法代码示例

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


在下文中一共展示了KeysConverter.ConvertToInvariantString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: OnLoad

        void OnLoad(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new EventHandler(OnLoad), new object[] { sender, e });
                return;
            }

            Application.DoEvents();

            KeysConverter kc = new KeysConverter();
            string key = _primary ?
                kc.ConvertToInvariantString(ShortcutMapper.KeyCommands[(int)_cmd].KeyData) :
                kc.ConvertToInvariantString(ShortcutMapper.AltKeyCommands[(int)_cmd].KeyData);


            lblDesc.Text = Translator.Translate("TXT_EDITKEYDESC",
                _cmd.ToString().Replace("Cmd", string.Empty), key);

            this.Height = pnlContentAll.Height + CaptionButtonSize.Height + pnlContentAll.Margin.Vertical + 2;
            this.Width = pnlContentAll.Width + pnlContentAll.Margin.Horizontal;
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:22,代码来源:KeyCommandEditor.cs

示例3: VerifyShortcut

        private bool VerifyShortcut(KeyEventArgs args)
        {
            OPMShortcut cmd = ShortcutMapper.MapCommand(args.KeyData);
            if (cmd == OPMShortcut.CmdOutOfRange)
            {
                // Key combination currently not assigned so it's OK to use it.
                return true;
            }

            if (cmd == _cmd)
            {
                // Same command => ok to reassign.
                return true;
            }

            string cmdOld = cmd.ToString().Replace("Cmd", string.Empty);
            string cmdNew = _cmd.ToString().Replace("Cmd", string.Empty);

            KeysConverter kc = new KeysConverter();
            string key = kc.ConvertToInvariantString(args.KeyData);

            if ((args.KeyData == Keys.Space && ShortcutMapper.IsPlayer) || 
                !ShortcutMapper.IsConfigurableShortcut(cmd))
            {
                // Key combination currently assigned 
                // to a non-configurable command (e.g. F1 = help)
                MessageDisplay.Show(Translator.Translate("TXT_DUP_SHORTCUT_FIXED", key, cmdOld), 
                    Translator.Translate("TXT_DUPPLICATE_SHORTCUT"),
                    MessageBoxIcon.Warning);
                return false;
            }

            if (MessageDisplay.Query(Translator.Translate("TXT_DUP_SHORTCUT_CONFIRM", key, cmdOld, cmdNew), 
                    Translator.Translate("TXT_DUPPLICATE_SHORTCUT"),
                    MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
            {
                // Key combination already assigned and the user did not want to change it use it.
                return false;
            }

            // Unassign old shortcut
            if (ShortcutMapper.KeyCommands[(int)cmd].KeyData == args.KeyData)
            {
                // Was used for primary shortcut
                ShortcutMapper.KeyCommands[(int)cmd] = new KeyEventArgs(Keys.None);
            }
            else if (ShortcutMapper.AltKeyCommands[(int)cmd].KeyData == args.KeyData)
            {
                // Was used for alternate shortcut
                ShortcutMapper.AltKeyCommands[(int)cmd] = new KeyEventArgs(Keys.None);
            }

            return true;
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:54,代码来源:KeyCommandEditor.cs

示例4: WriteXML

        private void WriteXML(string file)
        {
            XElement root = new XElement("AutoFire");

            foreach (Control groupbox in form.Controls)
            {
                if (groupbox is GroupBox)
                {
                    XElement groupboxXML = new XElement("macro");

                    foreach (Control element in groupbox.Controls)
                    {

                        if (element is Panel)
                        {
                            XElement panelXML = new XElement("key_interval");

                            foreach (Control field in element.Controls)
                            {
                                if (field is Label)
                                    panelXML.Add(new XElement("name", ((Label)field).Text));

                                if (field is ComboBox)
                                    panelXML.Add(new XElement("key", ((ComboBox)field).SelectedIndex));

                                if (field is NumericUpDown)
                                    panelXML.Add(new XElement("interval", ((NumericUpDown)field).Value));
                            }

                            groupboxXML.Add(panelXML);
                        }

                        if (element is CheckBox)
                            groupboxXML.Add(new XElement("loop", ((CheckBox)element).Checked.ToString()));

                        if (element is TextBoxEX)
                        {
                            TextBoxEX textbox = element as TextBoxEX;

                            if (!textbox.BoxKeys.Equals(Keys.None))
                            {
                                XElement key = new XElement("activation-key");
                                KeysConverter kc = new KeysConverter();

                                key.Add(new XElement("label", textbox.Text));
                                key.Add(new XElement("winkeys", kc.ConvertToInvariantString(textbox.BoxKeys)));

                                groupboxXML.Add(key);
                            }
                        }
                    }
                    root.Add(groupboxXML);
                }
            }
            root.Save(file);
        }
开发者ID:println,项目名称:AutoFire_Lineage-csharp,代码行数:56,代码来源:Storage.cs

示例5: DisplayKeys

        public void DisplayKeys()
        {
            try
            {
                User32.LockWindowUpdate(this.Handle);

                this.SuspendLayout();

                lvShortcuts.Items.Clear();

                List<OPMShortcut> shortcuts = new List<OPMShortcut>();
                for (OPMShortcut cmd = ShortcutMapper.CmdFirst; cmd < ShortcutMapper.CmdLast; cmd++)
                {
                    shortcuts.Add(cmd);
                }

                shortcuts.Sort(ShortcutsSorter);

                StringBuilder sb = new StringBuilder();

                foreach(OPMShortcut cmd in shortcuts)
                {
                    if (ShortcutMapper.IsHiddenShortcut(cmd))
                        continue;

                    string cmdName = cmd.ToString();
                    string desc = Translator.Translate("TXT_" + cmdName.ToUpperInvariant());
                    KeysConverter kc = new KeysConverter();
                    string key = kc.ConvertToInvariantString(ShortcutMapper.KeyCommands[(int)cmd].KeyData);
                    string altKey = kc.ConvertToInvariantString(ShortcutMapper.AltKeyCommands[(int)cmd].KeyData);

                    ListViewItem item = new ListViewItem(cmdName.Replace("Cmd", string.Empty));

                    OPMListViewSubItem subItemDesc = new OPMListViewSubItem(item, desc);
                    OPMListViewSubItem subItemKey = null;
                    OPMListViewSubItem subItemAltKey = null;

                    if (ShortcutMapper.IsConfigurableShortcut(cmd))
                    {
                        subItemKey = new OPMListViewSubItem(_llEditKeys, item, key);
                        subItemAltKey = new OPMListViewSubItem(_llEditKeys, item, altKey);
                    }
                    else
                    {
                        subItemKey = new OPMListViewSubItem(item, key);
                        subItemAltKey = new OPMListViewSubItem(item, altKey);
                    }

                    item.SubItems.Add(subItemDesc);
                    item.SubItems.Add(subItemKey);
                    item.SubItems.Add(subItemAltKey);


                    item.Tag = cmd;
                    lvShortcuts.Items.Add(item);

                    sb.AppendLine("<tr>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(item.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(subItemDesc.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(subItemKey.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(subItemAltKey.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine("Yes");
                    sb.AppendLine("</td>");

                    sb.AppendLine("</tr>");
                }

                this.ResumeLayout();
            }
            finally
            {
                User32.LockWindowUpdate(IntPtr.Zero);
            }
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:88,代码来源:KeyMapCfgPanel.cs

示例6: UpdateKey

        private void UpdateKey(OPMShortcut cmd)
        {
            KeysConverter kc = new KeysConverter();
            string key = kc.ConvertToInvariantString(ShortcutMapper.KeyCommands[(int)cmd].KeyData);
            string altKey = kc.ConvertToInvariantString(ShortcutMapper.AltKeyCommands[(int)cmd].KeyData);

            for (int i = 0; i < lvShortcuts.Items.Count; i++)
            {
                ListViewItem row = lvShortcuts.Items[i];
                if ((OPMShortcut)(row.Tag) == cmd)
                {
                    row.SubItems[hdrKey.Index].Text = key;
                    row.SubItems[hdrAltkey.Index].Text = altKey;
                }
            }
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:16,代码来源:KeyMapCfgPanel.cs

示例7: SaveComponentSettings

 public void SaveComponentSettings()
 {
     Dictionary<Keys, IComponent> dictionary = new Dictionary<Keys, IComponent>(Settings.Default.DefaultKeyMap);
     Dictionary<IComponent, List<Keys>> dictionary2 = new Dictionary<IComponent, List<Keys>>();
     foreach (KeyValuePair<Keys, IComponent> pair in this.KeyMap)
     {
         IComponent component;
         if (!dictionary.TryGetValue(pair.Key, out component))
         {
             dictionary2[pair.Value] = null;
         }
         else if (component != pair.Value)
         {
             dictionary2[component] = null;
             dictionary2[pair.Value] = null;
         }
         dictionary.Remove(pair.Key);
     }
     foreach (KeyValuePair<Keys, IComponent> pair in dictionary)
     {
         dictionary2[pair.Value] = null;
     }
     foreach (KeyValuePair<Keys, IComponent> pair in this.KeyMap)
     {
         List<Keys> list;
         if (dictionary2.TryGetValue(pair.Value, out list))
         {
             if (list == null)
             {
                 list = new List<Keys>();
                 dictionary2[pair.Value] = list;
             }
             list.Add(pair.Key);
         }
     }
     TypeConverter converter = new KeysConverter();
     StringBuilder builder = new StringBuilder();
     foreach (KeyValuePair<IComponent, List<Keys>> pair2 in dictionary2)
     {
         if (builder.Length > 0)
         {
             builder.AppendLine();
         }
         builder.Append(GetCommandName(pair2.Key));
         if (pair2.Value != null)
         {
             foreach (Keys keys in pair2.Value)
             {
                 builder.Append(',');
                 builder.Append(converter.ConvertToInvariantString(keys));
             }
         }
     }
     Settings.Default.KeyboardMap = builder.ToString();
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:55,代码来源:KeyboardMapOptionControl.cs

示例8: SaveInternal

        private static void SaveInternal(Stream s)
        {
            using (StreamWriter sw = new StreamWriter(s))
            {
                KeysConverter kc = new KeysConverter();

                for (OPMShortcut cmd = CmdFirst; cmd < CmdLast; cmd++)
                {
                    sw.WriteLine("{0};{1};{2}",
                        cmd, 
                        kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData), 
                        kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData));
                }
            }
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:15,代码来源:ShortcutMapper.cs

示例9: GetShortcutString

        public static string GetShortcutString(OPMShortcut cmd)
        {
            if (cmd >= OPMShortcut.CmdPlayPause && cmd < OPMShortcut.CmdOutOfRange)
            {
                KeysConverter kc = new KeysConverter();
                
                string actionKeys =
                   kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData);
                string altActionKeys =
                    kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData);

                if (actionKeys == altActionKeys)
                    return actionKeys;
                else
                    return actionKeys + " " + Translator.Translate("TXT_OR") + " " + altActionKeys;

            }

            return string.Empty;
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:20,代码来源:ShortcutMapper.cs

示例10: MapCommand

        public static OPMShortcut MapCommand(Keys key)
        {
            if (key == Keys.Space)
                return OPMShortcut.CmdPlayPause;

            KeysConverter kc = new KeysConverter();
            string pressedKeys = kc.ConvertToInvariantString(key);

            for (OPMShortcut cmd = CmdFirst; cmd < CmdLast; cmd++)
            {
                string actionKeys = 
                    kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData);
                string altActionKeys = 
                    kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData);

                if (pressedKeys == actionKeys || pressedKeys == altActionKeys)
                    return cmd;
            }

            return OPMShortcut.CmdOutOfRange;
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:21,代码来源:ShortcutMapper.cs


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