예제 #1
0
        private void AutoTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                // Verification.
                if (string.IsNullOrEmpty(autoTextBox.Text))
                {
                    // Disable.
                    CloseAutoSuggestionBox();

                    return;
                }

                // Enable.
                OpenAutoSuggestionBox();

                // Settings.
                autoList.ItemsSource = SuggestionList.Where(p => p.ToLower().Contains(autoTextBox.Text.ToLower())).ToList();
            }
            catch (Exception ex)
            {
                // Info.
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Console.Write(ex);
            }
        }
        // GET: Suggestion
        public ActionResult Index()
        {
            SuggestionList pl = new SuggestionList();

            pl.Suggestion = db.Suggestions.ToList();
            //pl.newGuy = new Person();
            return(View(pl));
        }
예제 #3
0
        public void SelectFromSuggestionList()
        {
            textBox.Enter("h");
            SuggestionList suggestionList = textBox.SuggestionList;

            suggestionList.Select("hello");
            Assert.AreEqual("hello", textBox.Text);
        }
예제 #4
0
        public void SuggestionList()
        {
            textBox.Text = "h";
            SuggestionList suggestionList = textBox.SuggestionList;

            Assert.AreEqual(2, suggestionList.Items.Count);
            Assert.AreEqual("hello", suggestionList.Items[0]);
            Assert.AreEqual("hi", suggestionList.Items[1]);
        }
예제 #5
0
파일: Parser.cs 프로젝트: fence-post/sqrach
        static void UpdateSuggestions(string keyword)
        {
            SuggestionList list = Parser.GetSuggestions(keyword);

            if (list != null)
            {
                querySuggestions.Add(keyword, list);
            }
        }
예제 #6
0
        public void Should_throw_comparing_to_null()
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                SuggestionList suggestionList = new SuggestionList(5);
                Assert.AreEqual(1, suggestionList.CompareTo(null));

                Assert.Throws <ArgumentException>(() => suggestionList.CompareTo(new Connector(5)));
            }
        }
예제 #7
0
        public void Should_init_suggestion_list_properly()
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                SuggestionList suggestionList = new SuggestionList(10);
                Assert.AreEqual(10, suggestionList.TotalSum);

                Assert.DoesNotThrow(() => new SuggestionList());
            }
        }
예제 #8
0
        void SelectFromSuggestionList()
        {
            var textBox = MainWindow.Get <WinFormTextBox>("TextBox");

            textBox.Enter("h");
            SuggestionList suggestionList = textBox.SuggestionList;

            suggestionList.Select("hello");
            Assert.Equal("hello", textBox.Text);
        }
예제 #9
0
        void SuggestionList()
        {
            var textBox = MainWindow.Get <WinFormTextBox>("TextBox");

            textBox.Text = "h";
            SuggestionList suggestionList = textBox.SuggestionList;

            Assert.Equal(2, suggestionList.Items.Count);
            Assert.Equal("hello", suggestionList.Items[0]);
            Assert.Equal("hi", suggestionList.Items[1]);
        }
예제 #10
0
        public void Should_merge_1_suggestion_list_with_connector()
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                SuggestionList suggestionList = new SuggestionList(5);
                suggestionList.Add(new Suggestion(Guid.NewGuid(), 1, 5));

                Connector connector = new Connector(1, 5f);

                SuggestionList suggestionList3 = new SuggestionList(suggestionList, connector);

                Assert.AreEqual(10, suggestionList3.TotalSum);
                Assert.AreEqual(2, suggestionList3.Count);
            }
        }
예제 #11
0
파일: Parser.cs 프로젝트: fence-post/sqrach
        public static SuggestionList GetSuggestions(string keyword)
        {
            fp.lib.sqlparser.Query q = T.Coalesce(Parser.currentQuery, query);
            if (q != null)
            {
                lock (query)
                {
                    SuggestionList suggestions = new SuggestionList(q, keyword);
                    if (suggestions.BuildSuggestionList() > 0)
                    {
                        return(suggestions);
                    }
                }
            }

            return(null);
        }
        public ActionResult Index([Bind(Include = "SuggestionID, Name, Comment")] Suggestion newPerson)
        {
            ModelState.Clear();
            SuggestionList pl = new SuggestionList();

            pl.newPerson = new Suggestion {
                Name = "", Comment = ""
            };
            if (!CreateSuggestion(newPerson))
            {
                pl.newPerson = newPerson;
            }

            pl.Suggestion = db.Suggestions.ToList();


            return(PartialView(pl));
        }
예제 #13
0
        public IEnumerable <Revelation> MakeSuggestion(Suggestion suggestion)
        {
            SuggestionList.Add(suggestion);
            var revelations    = new HashSet <Revelation>();
            var playersToCheck = new SortedSet <string>(AllPlayers);

            playersToCheck.Remove(suggestion.Suggester);
            playersToCheck.Remove(EnvelopePlayer);
            foreach (var player in playersToCheck)
            {
                ISet <Card> cards = new HashSet <Card>(PlayerHand(player));
                cards.IntersectWith(suggestion.SuggestedCards);
                if (cards.Count > 0)
                {
                    revelations.Add(new Revelation(player, null));
                }
            }

            return(revelations);
        }
예제 #14
0
        bool OnTextChanged(bool showAutoComplete)
        {
            selectedQuery.query = editor.Text;
            Parser.TextChanged(editor.Text, editor.CurrentPosition, false);
            if (showAutoComplete)
            {
                SuggestionList suggestions = Parser.GetSuggestions(editor.Text, editor.CurrentPosition);
                if (suggestions != null)
                {
                    if (!autoComplete.UpdateSuggestions(suggestions,
                                                        editor.PointToScreen(new Point(editor.PointXFromPosition(suggestions.wordStartPosition),
                                                                                       editor.PointYFromPosition(suggestions.wordStartPosition)))))
                    {
                        showAutoComplete = false;
                    }
                }
            }

            return(showAutoComplete);
        }
예제 #15
0
        public void Should_merge_2_suggestion_lists()
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                SuggestionList suggestionList = new SuggestionList(5);
                suggestionList.Add(new Suggestion(Guid.NewGuid(), 1, 5));

                SuggestionList suggestionList2 = new SuggestionList(10);
                suggestionList2.Add(new Suggestion(Guid.NewGuid(), 1, 5));
                suggestionList2.Add(new Suggestion(Guid.NewGuid(), 2, 5));

                Assert.Less(0, suggestionList2.CompareTo(suggestionList));

                SuggestionList suggestionList3 = new SuggestionList(suggestionList, suggestionList2);

                Assert.AreEqual(15, suggestionList3.TotalSum);
                Assert.AreEqual(3, suggestionList3.Count);

                Assert.DoesNotThrow(() => new SuggestionList());
            }
        }
예제 #16
0
파일: Parser.cs 프로젝트: fence-post/sqrach
        public static SuggestionList GetSuggestions(string text, int position)
        {
            if (Parser.currentQuery != null)
            {
                lock (query)
                {
                    SuggestionList suggestions = new SuggestionList(Parser.currentQuery, Parser.currentKeyword);
                    suggestions.enableSuggestColumns     = S.Get("AutocompleteColumns", true);
                    suggestions.enableSuggestTables      = S.Get("AutocompleteTables", true);
                    suggestions.enableSuggestAliases     = S.Get("AutocompleteAliases", true);
                    suggestions.enableAutoSuggestAliases = S.Get("AutocompleteInsertAliases", false);
                    suggestions.enableSuggestKeywords    = S.Get("AutocompleteKeywords", true);
                    suggestions.enableSuggestJoins       = S.Get("AutocompleteJoins", true);
                    if (suggestions.BuildSuggestionList(text, position) > 0)
                    {
                        return(suggestions);
                    }
                }
            }

            return(null);
        }
    public override void Run()
    {
        if (Npp.Editor.GetCurrentFilePath().EndsWith(".dsl"))
        {
            string   hint        = Editor.GetSuggestionHint();
            string[] suggestions = Parser.GetSuggestions(hint);
            Point    caretPoint  = Npp.GetCaretScreenLocation();

            Form form;

            if (suggestions.Length > 0)
            {
                form = new SuggestionList(suggestions, caretPoint, Editor.ApplySuggestion);
            }
            else
            {
                form = new SuggestionList(new[] { "< no suggestions >" }, caretPoint);
            }

            form.Show();
        }
    }
예제 #18
0
        public bool UpdateSuggestions(SuggestionList suggestions, Point p)
        {
            suggestionList = suggestions;
            theList.Sorted = false; //  !suggestionList.queryMode;

            Point pOrig = p;

            p = parent.PointToClient(p);

            leftWidth   = 0;
            rightWidth  = 0;
            middleWidth = 0;

            int lineHeight = theList.ItemHeight = FormsToolbox.GetTextHeight("0", this.Font) + 4;

            // suggestions.Clear();
            if (suggestions != null && suggestions.Count > 0)
            {
                int maxWidth = 0;
                theList.BeginUpdate();
                theList.Items.Clear();
                theList.SelectedIndex = -1;
                Suggestion selectedItem = null;
                string     match        = suggestions.textEntered.ToLower().Trim();
                foreach (Suggestion s in suggestions.GetSuggestions(!suggestionList.queryMode, match))
                {
                    if (s.expr.Trim().Length > 0)
                    {
                        if (s.expr.ToLower().Contains(match))
                        {
                            leftWidth = Math.Max(leftWidth, 20 + FormsToolbox.GetTextWidth(s.expr + "00", Font));
                            if (s.middleStuff != null)
                            {
                                middleWidth = Math.Max(middleWidth, FormsToolbox.GetTextWidth(s.middleStuff + "00", SystemFonts.MessageBoxFont));
                            }
                            if (s.rightStuff != null)
                            {
                                rightWidth = Math.Max(rightWidth, FormsToolbox.GetTextWidth(s.rightStuff + "00", SystemFonts.MessageBoxFont));
                            }
                            theList.Items.Add(s);
                            if (s.expr.ToLower().StartsWith(match) &&
                                (selectedItem == null || s.position < selectedItem.position))
                            {
                                selectedItem = s;
                            }
                        }
                    }
                }
                theList.EndUpdate();
                if (selectedItem != null)
                {
                    theList.SelectedItem = selectedItem;
                    int topItem = Math.Max(0, theList.SelectedIndex - (maxVisibleItems / 2));
                    theList.TopIndex = topItem;
                }

                maxWidth = leftWidth + middleWidth + rightWidth;

                if (theList.Items.Count > 0)
                {
                    if (!Visible)
                    {
                        Show();
                        BringToFront();
                    }
                    T.Debug(p.Y.ToString() + " " + pOrig.Y.ToString());
                    int maxHeight = maxVisibleItems * lineHeight;
                    theList.Size = new Size(T.MinMax(20, 600, maxWidth), T.MinMax(lineHeight, maxHeight, lineHeight * theList.Items.Count));
                    int y = p.Y;
                    if (!suggestionList.queryMode)
                    {
                        y += lineHeight;
                    }
                    Bounds = new Rectangle(p.X, y, theList.Width, theList.Height);
                    editor.Focus();
                    return(theList.Items.Count > 0);
                }
            }
            Hide();
            editor.Focus();
            return(false);
        }