Пример #1
0
        public Data()
        {
            type = new int[18] {
                0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0
            };
            oldK = new Keys[18];
            newK = new Keys[18];
            p    = new Point[18];
            code = new short[18] {
                0x4D, 0x4A, 0x48, 0x56, 0x50, 0, 0, 0, 0, 0, 0, 0, 0x67, 0x68, 0x64, 0x65, 0x61, 0x62
            };
            XDocument     xdoc = XDocument.Load("Bindings.xml");
            KeysConverter kc   = new KeysConverter();
            int           i    = 0;

            foreach (XElement bind in xdoc.Element("Bindings").Elements("Bind"))
            {
                oldK[i] = (Keys)kc.ConvertFromInvariantString(bind.Element("oldKey").Value);
                if (kc.ConvertFromInvariantString(bind.Element("newKey").Value) != null)
                {
                    newK[i] = (Keys)kc.ConvertFromInvariantString(bind.Element("newKey").Value);
                }
                i++;
            }
            p[5].X  = 1452; p[5].Y = 936;
            p[6].X  = 1535; p[6].Y = 936;
            p[7].X  = 1602; p[7].Y = 936;
            p[8].X  = 1375; p[8].Y = 1009;
            p[9].X  = 1452; p[9].Y = 1009;
            p[10].X = 1535; p[10].Y = 1009;
            p[11].X = 1602; p[11].Y = 1009;
        }
Пример #2
0
 private bool MaybeUpdateKey()
 {
     if (hotkeyTextBox.Text.Length == 0 || !enabledKeyBox.Checked)
     {
         Properties.Settings.Default.OpenShortcut = Keys.None;
         return(true);
     }
     else
     {
         try
         {
             object keyObject = _keysConverter.ConvertFromInvariantString(hotkeyTextBox.Text);
             if (keyObject == null)
             {
                 throw new ArgumentException();
             }
             Properties.Settings.Default.OpenShortcut = (Keys)keyObject;
         }
         catch (ArgumentException)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #3
0
 public MainApplicationContext() : base(Resources.PinWinIconWhite)
 {
     ContextMenu.Opening += ContextMenu_Opening;
     if (!String.IsNullOrWhiteSpace(Settings.Default.HotKey))
     {
         var  keyConv = new KeysConverter();
         Keys keys    = (Keys)keyConv.ConvertFromInvariantString(Settings.Default.HotKey);
         SetHotKey((KeyCombination)keys);
     }
     Application.ApplicationExit += Application_ApplicationExit;
     updateChecker = new WinFormsUpdateChecker(Program.UPDATE_URL, identifier: Program.UPDATE_IDENTIFIER);
     if (Settings.Default.AlwaysCheckForUpdates)
     {
         updateChecker.CheckForUpdates();
     }
 }
        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);
            }
        }
        public static void Load()
        {
            try
            {
                KeysConverter kc = new KeysConverter();

                string keymap = PersistenceProxy.ReadObject(true, "Keymap", string.Empty);
                if (string.IsNullOrEmpty(keymap) == false)
                {
                    string[] lines = keymap.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (lines != null)
                    {
                        foreach (string line in lines)
                        {
                            string[] fields = line.Split(";".ToCharArray());
                            if (fields.Length >= 2)
                            {
                                OPMShortcut cmd = (OPMShortcut)Enum.Parse(typeof(OPMShortcut), fields[0]);
                                keyCommands[(int)cmd] = new KeyEventArgs((Keys)kc.ConvertFromInvariantString(fields[1]));

                                if (fields.Length >= 3)
                                {
                                    altKeyCommands[(int)cmd] = new KeyEventArgs((Keys)kc.ConvertFromInvariantString(fields[2]));
                                }
                                else
                                {
                                    altKeyCommands[(int)cmd] = new KeyEventArgs(keyCommands[(int)cmd].KeyData);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
Пример #6
0
        private bool MaybeUpdateKey()
        {
            if ((enabledBox.Checked == false || hotkeyTextBox.Text.Length == 0) && _orignalKey != Keys.None)
            {
                using (var ctx = new FilesContext())
                {
                    ctx.UpdateShortcuts(_watcher, Keys.None, globalBox.Checked);
                }
            }
            else
            {
                try
                {
                    object keyObject = _keysConverter.ConvertFromInvariantString(hotkeyTextBox.Text);
                    if (keyObject == null)
                    {
                        throw new ArgumentException();
                    }

                    if (_orignalGlobalKeyBool != globalBox.Checked || (Keys)keyObject != _orignalKey)
                    {
                        using (var ctx = new FilesContext())
                        {
                            ctx.UpdateShortcuts(_watcher, (Keys)keyObject, globalBox.Checked);
                        }
                    }
                }
                catch (ArgumentException)
                {
                    MessageBox.Show("Invalid key", "Could not set this key.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            _watcherKeyManager.UpdateDataAndEnable();
            return(true);
        }
        private static Keys GetKey(string a)
        {
            KeysConverter kc = new KeysConverter();

            return((Keys)kc.ConvertFromInvariantString(a.ToUpperInvariant()));
        }
Пример #8
0
        public static int ConvertStringToKeys(string shortcut)
        {
            var conv = new KeysConverter();

            return((int)conv.ConvertFromInvariantString(shortcut));
        }