예제 #1
0
 public InputBinding(ICommand command, Chord chord, object commandContext)
 {
     this.command        = command;
     this.chord          = chord;
     this.commandContext = commandContext;
 }
예제 #2
0
        static ChordMessageFilter()
        {
            ChordMessageFilter.constants.Add(131072);
            ChordMessageFilter.constants.Add(17);
            ChordMessageFilter.constants.Add(18);
            ChordMessageFilter.constants.Add(262144);
            ChordMessageFilter.constants.Add(65536);
            ChordMessageFilter.constants.Add(16);
            ChordMessageFilter.validKeys = new Keys[94]
            {
                Keys.A,
                Keys.B,
                Keys.C,
                Keys.D,
                Keys.D0,
                Keys.D1,
                Keys.D2,
                Keys.D3,
                Keys.D4,
                Keys.D5,
                Keys.D6,
                Keys.D7,
                Keys.D8,
                Keys.D9,
                Keys.Delete,
                Keys.Down,
                Keys.E,
                Keys.End,
                Keys.F,
                Keys.F1,
                Keys.F10,
                Keys.F11,
                Keys.F12,
                Keys.F13,
                Keys.F14,
                Keys.F15,
                Keys.F16,
                Keys.F17,
                Keys.F18,
                Keys.F19,
                Keys.F2,
                Keys.F20,
                Keys.F21,
                Keys.F22,
                Keys.F23,
                Keys.F24,
                Keys.F3,
                Keys.F4,
                Keys.F5,
                Keys.F6,
                Keys.F7,
                Keys.F8,
                Keys.F9,
                Keys.G,
                Keys.H,
                Keys.I,
                Keys.Insert,
                Keys.J,
                Keys.K,
                Keys.L,
                Keys.Left,
                Keys.M,
                Keys.N,
                Keys.NumLock,
                Keys.NumPad0,
                Keys.NumPad1,
                Keys.NumPad2,
                Keys.NumPad3,
                Keys.NumPad4,
                Keys.NumPad5,
                Keys.NumPad6,
                Keys.NumPad7,
                Keys.NumPad8,
                Keys.NumPad9,
                Keys.O,
                Keys.OemBackslash,
                Keys.OemClear,
                Keys.OemCloseBrackets,
                Keys.Oemcomma,
                Keys.OemMinus,
                Keys.OemOpenBrackets,
                Keys.OemPeriod,
                Keys.OemPipe,
                Keys.Oemplus,
                Keys.OemQuestion,
                Keys.OemQuotes,
                Keys.OemSemicolon,
                Keys.Oemtilde,
                Keys.P,
                Keys.Pause,
                Keys.Q,
                Keys.R,
                Keys.Right,
                Keys.S,
                Keys.Space,
                Keys.T,
                Keys.Tab,
                Keys.U,
                Keys.Up,
                Keys.V,
                Keys.W,
                Keys.X,
                Keys.Y,
                Keys.Z
            };
            ChordMessageFilter.testKeys = new List <Keys>();
            ChordMessageFilter.testKeys.Add(Keys.D1);
            ChordMessageFilter.testKeys.Add(Keys.D2);
            ChordModifier chordModifier = new ChordModifier(false, true, true);

            ChordMessageFilter.testChord         = new Chord(ChordMessageFilter.testKeys, chordModifier);
            ChordMessageFilter.registeredFilters = new List <ChordMessageFilter>();
        }
예제 #3
0
        public override object ConvertFrom(
            ITypeDescriptorContext context,
            CultureInfo culture,
            object value)
        {
            if (!(value is string))
            {
                return(base.ConvertFrom(context, culture, value));
            }
            string a     = ((string)value).Trim();
            Chord  chord = new Chord();

            if (!string.Equals(a, string.Empty))
            {
                List <Keys> keysList = new List <Keys>();
                string[]    strArray = a.Split(ChordConverter.separator.ToCharArray());
                for (int index = 0; index < strArray.Length; ++index)
                {
                    strArray[index] = strArray[index].Trim();
                    strArray[index] = strArray[index].ToUpper();
                }
                Keys   keys1  = Keys.None;
                object keyMap = ChordConverter.KeyMaps[(object)ChordConverter.separator.ToCharArray()];
                if (keyMap != null)
                {
                    keys1 = (Keys)keyMap;
                }
                for (int index1 = 0; index1 < strArray.Length; ++index1)
                {
                    Keys keys2 = Keys.None;
                    foreach (string key in (IEnumerable)ChordConverter.KeyMaps.Keys)
                    {
                        if (strArray[index1] == key.ToUpper())
                        {
                            keys2 = (Keys)ChordConverter.KeyMaps[(object)key];
                            break;
                        }
                    }
                    if (keys2 == Keys.None)
                    {
                        try
                        {
                            object obj = Enum.Parse(typeof(Keys), strArray[index1]);
                            if (obj != null)
                            {
                                keys2 = (Keys)obj;
                            }
                        }
                        catch (ArgumentException ex)
                        {
                        }
                    }
                    if (keys2 != Keys.None)
                    {
                        if (keys2 == Keys.Menu)
                        {
                            chord.ChordModifier.AltModifier = true;
                        }
                        else if (keys2 == Keys.ControlKey)
                        {
                            chord.ChordModifier.ControlModifier = true;
                        }
                        else if (keys2 == Keys.ShiftKey)
                        {
                            chord.ChordModifier.ShiftModifier = true;
                        }
                        else
                        {
                            keysList.Add(keys2);
                        }
                    }
                    else if (string.IsNullOrEmpty(strArray[index1]))
                    {
                        bool flag   = false;
                        int  index2 = index1;
                        int  num    = 0;
                        while (!flag)
                        {
                            if (string.IsNullOrEmpty(strArray[index2]))
                            {
                                ++num;
                            }
                            if (num == 2)
                            {
                                num = 0;
                                if (keys1 != Keys.None)
                                {
                                    keysList.Add(keys1);
                                }
                                else
                                {
                                    try
                                    {
                                        object obj = Enum.Parse(typeof(Keys), ChordConverter.separator);
                                        if (obj != null)
                                        {
                                            keysList.Add((Keys)obj);
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            if (string.IsNullOrEmpty(strArray[index2]) && index2 + 1 < strArray.Length)
                            {
                                ++index2;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        for (int index2 = 0; index2 < strArray[index1].Length; ++index2)
                        {
                            try
                            {
                                object obj = Enum.Parse(typeof(Keys), strArray[index1][index2].ToString().ToUpper());
                                if (obj != null)
                                {
                                    keysList.Add((Keys)obj);
                                }
                            }
                            catch (ArgumentException ex)
                            {
                                throw new FormatException("Invalid Key Name: " + (object)strArray[index1][index2]);
                            }
                        }
                    }
                }
                if (!chord.ChordModifier.IsEmpty || keysList.Count > 0)
                {
                    chord.KeysInternal = keysList;
                    return((object)chord);
                }
            }
            return((object)null);
        }