Exemple #1
0
        /// <summary>
        /// values:
        /// [LAlt],[RAlt],[LShift],[RShift],[LCtrl],[RCtrl],[LWin],[RWin],[Key_Code]
        /// </summary>
        /// <param name="trhk"> raw hotkey from tray menu Mahou.mm</param>
        /// <returns></returns>
        public static Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> > tray_hk_parse(string trhk)
        {
            bool la, ra, ls, rs, lc, rc, lw, rw; int kc = 0;

            la = ra = ls = rs = lc = rc = lw = rw = false;
            var p = trhk.ToLower().Substring(2, trhk.Length - 2).Split('+');

            foreach (var x in p)
            {
                switch (x)
                {
                case "lalt": la = true; break;

                case "ralt": ra = true; break;

                case "lshift": ls = true; break;

                case "rshift": rs = true; break;

                case "lctrl": lc = true; break;

                case "rctrl": rc = true; break;

                case "lwin": lw = true; break;

                case "rwin": rw = true; break;

                default:
//				System.Diagnostics.Debug.WriteLine("x = " +x);
                    if (!string.IsNullOrEmpty(x))
                    {
                        var l = KMHook.strparsekey(x);
                        if (l.Count > 0)
                        {
                            kc = (int)l[0];
                        }
                    }
                    break;
                }
            }
            return(new Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> >(la, ra, ls, rs, lc, rc, lw, new Tuple <bool, int>(rw, kc)));
        }
Exemple #2
0
// for debugging
//		public static string tray_hk_to_string(Tuple<bool, bool, bool, bool, bool, bool, bool, Tuple<bool, int>> trhk) {
//			var strhk = "";
//			if(trhk.Item1) { strhk += "lalt+"; }
//			if(trhk.Item2) { strhk += "ralt+"; }
//			if(trhk.Item3) { strhk += "lshift+"; }
//			if(trhk.Item4) { strhk += "rshift+"; }
//			if(trhk.Item5) { strhk += "lctrl"; }
//			if(trhk.Item6) { strhk += "rctrl+"; }
//			if(trhk.Item7) { strhk += "lwin+"; }
//			if(trhk.Rest.Item1) { strhk += "rwin+"; }
//			strhk += ((Keys)trhk.Rest.Item2).ToString();
//			return strhk;
//		}
        /// <summary>
        /// values:
        /// [LAlt],[RAlt],[LShift],[RShift],[LCtrl],[RCtrl],[LWin],[RWin],[Key_Code]
        /// </summary>
        /// <param name="trhk"> raw hotkey from tray menu Mahou.mm</param>
        /// <returns></returns>
        public static Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> > tray_hk_parse(string trhk)
        {
            bool la, ra, ls, rs, lc, rc, lw, rw; int kc = 0;

            la = ra = ls = rs = lc = rc = lw = rw = false;
            if (trhk.Contains("&&"))
            {
                trhk = trhk.Split(new [] { "&&" }, StringSplitOptions.None)[0];
            }
            var p = trhk.ToLower().Substring(2, trhk.Length - 2).Split('+');

            foreach (var x in p)
            {
//				System.Diagnostics.Debug.WriteLine("X: " +x);
                switch (x)
                {
                case "lalt": la = true; break;

                case "ralt": ra = true; break;

                case "lshift": ls = true; break;

                case "rshift": rs = true; break;

                case "lctrl": lc = true; break;

                case "rctrl": rc = true; break;

                case "lwin": lw = true; break;

                case "rwin": rw = true; break;

                default:
//					System.Diagnostics.Debug.WriteLine("x = " +x);
                    if (!string.IsNullOrEmpty(x))
                    {
                        if (x.ToLower() == "laltkey")
                        {
                            kc = (int)Keys.LMenu;
                        }
                        else if (x.ToLower() == "raltkey")
                        {
                            kc = (int)Keys.LMenu;
                        }
                        else if (x.ToLower() == "lwinkey")
                        {
                            kc = (int)Keys.LWin;
                        }
                        else if (x.ToLower() == "rwinkey")
                        {
                            kc = (int)Keys.RWin;
                        }
                        else
                        {
                            var l = KMHook.strparsekey(x);
                            if (l.Count > 0)
                            {
                                kc = (int)l[0];
                            }
                        }
                    }
                    break;
                }
            }
            return(new Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> >(la, ra, ls, rs, lc, rc, lw, new Tuple <bool, int>(rw, kc)));
        }