Exemplo n.º 1
0
        public FalconKeyCallbackFilter(ICollectionView filteredView, TextBox textBox)
        {
            string filterText = "";

            if (filteredView != null)
            {
                filteredView.Filter = delegate(object obj)
                {
                    if (String.IsNullOrEmpty(filterText))
                    {
                        return(true);
                    }

                    FalconKeyCallback callback = obj as FalconKeyCallback;
                    int nameIndex = callback.Name.IndexOf(filterText, 0, StringComparison.InvariantCultureIgnoreCase);
                    int descIndex = callback.Description.IndexOf(filterText, 0, StringComparison.InvariantCultureIgnoreCase);
                    return(nameIndex > -1 || descIndex > -1);
                };

                textBox.TextChanged += delegate
                {
                    filterText = textBox.Text;
                    filteredView.Refresh();
                };
            }
        }
Exemplo n.º 2
0
        private void ParseKeys(string keyFile)
        {
            if (File.Exists(keyFile))
            {
                KeyFileExists = true;
                using (StreamReader reader = File.OpenText(keyFile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Length > 0 && line[0] != '#')
                        {
                            //string[] tokens = line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                            string[] tokens = SplitArgument(line);

                            if (tokens.Length >= 2)
                            {
                                string callbackName = tokens[0];
                                int    isKey        = int.Parse(tokens[2]);
                                if (isKey == 0)
                                {
                                    FalconKeyCallback callback = new FalconKeyCallback(callbackName)
                                    {
                                        KeyCode        = ConvertString(tokens[3]),
                                        Modifiers      = ConvertString(tokens[4]),
                                        ComboKeyCode   = ConvertString(tokens[5]),
                                        ComboModifiers = ConvertString(tokens[6])
                                    };
                                    if (tokens.Length >= 9)
                                    {
                                        callback.Description = tokens[8];
                                    }
                                    if (!_callbacks.ContainsKey(callbackName) && callback.KeyCode > 0)
                                    {
                                        _callbacks.Add(callbackName, callback);
                                    }
                                }
                            }
                        }
                    }
                }

                _callbackList = new List <FalconKeyCallback>(_callbacks.Values);
                if (_callbackList.Count > 0)
                {
                    _parsed = true;
                    _callbackList.Sort();
                }
                else
                {
                    _parsed = false;
                }
            }
            else
            {
                KeyFileExists = false;
            }
        }