コード例 #1
0
        private void UpdateCurrentSuggestionSource()
        {
            LogTo.Debug("Update started.");
            var start     = DateTime.Now;
            var htmlCtrls = ContentUtils.GetHtmlCtrls();

            if (htmlCtrls == null)
            {
                LogTo.Debug("Failed to update current suggestion source because htmlCtrls was null");
                return;
            }

            var newSuggestionss = BaseSuggestions.Copy();

            foreach (var htmlCtrl in htmlCtrls)
            {
                var doc  = htmlCtrl?.GetDocument();
                var text = doc?.body?.innerText;
                if (string.IsNullOrEmpty(text))
                {
                    continue;
                }

                var words = SplitIntoWords(text);
                if (words == null)
                {
                    return;
                }

                newSuggestionss.AddWords(words);
            }
            CurrentSuggestions = newSuggestionss;
            LogTo.Debug("Update took: " + (DateTime.Now - start).TotalMilliseconds.ToString() + "ms");
        }
コード例 #2
0
        public bool AddWords(IEnumerable <KeyValuePair <string, string> > keyValuePairs)
        {
            var words = keyValuePairs?.Select(x => new StringEntry <string>(x.Key, x.Value));

            if (words == null)
            {
                return(false);
            }

            CurrentSuggestions.AddWords(words);
            BaseSuggestions.AddWords(words);
            return(true);
        }
コード例 #3
0
        private void CreateInitialSuggestions()
        {
            var words = Words.LoadWords()?.Select(x => new StringEntry <string>(x, x));

            if (words != null)
            {
                BaseSuggestions.AddWords(words);
                BaseSuggestions.AddWords(new[]
                {
                    new StringEntry <string>("nats ℕ", "nats ℕ"),
                    new StringEntry <string>("rats ℚ", "rats ℚ"),
                    new StringEntry <string>("reals ℝ", "reals ℝ"),
                    new StringEntry <string>("isin ∊", "isin ∊"),
                    new StringEntry <string>("notin ∉", "notin ∉"),
                    new StringEntry <string>("delta ∆", "delta ∆"),
                    new StringEntry <string>("prod ×", "prod ×"),
                    new StringEntry <string>("empty Ø", "empty Ø"),
                    new StringEntry <string>("ints ℤ", "ints ℤ"),
                    new StringEntry <string>("set { ... | ... }", "set { ... | ... }"),
                });
                CurrentSuggestions = BaseSuggestions.Copy();
            }
        }