Пример #1
0
        /// <summary>
        /// strip a keylist of unmanaged keys and ctrl,alt,shifts, returning a new array
        /// </summary>
        /// <param name="klist">key list to strip unmanaged keys from</param>
        /// <param name="k">keyboard handler object</param>
        /// <returns>array with keys stripped (new memory array if unmanaged key list has items or removemodifiersfromkeylist is true)</returns>
        private static void Strip(ref Keys[] klist, KBHandler k)
        {
            //return original array reference if nothing in the unmanaged list
            if (k.unmanaged.Count == 0 && k.removemodifiersfromkeylist == false)
            {
                return;
            }
            int a;
            int b = 0;

            for (a = 0; a < klist.Length; a++)
            {
                if (!((k.removemodifiersfromkeylist == true && KBHelper.IsMod(klist[a])) || k.unmanaged.Contains(klist[a])))
                {//if not modifier and not in unmanaged list then copy the value to next valid part in array, otherwise skip over(a will advance, b will stay the same and then next time the modiffier/unmanaged key will be overwritten by a good key)
                    klist[b] = klist[a];
                    b++;
                }
            }
            if (b < a)
            {
                Keys[] newlist = new Keys[b];
                for (int j = 0; j < b; j++)
                {
                    newlist[j] = klist[j];
                }
                klist = newlist;
            }
        }