Example #1
0
 public TokenBox()
 {
     InitializeComponent();
     this.tb.Margin = new Padding(4, 7, 2, 4);
     this.Controls.Add(tb);
     this.MouseClick     += new System.Windows.Forms.MouseEventHandler(this.mouseClick);
     this.ControlAdded   += new System.Windows.Forms.ControlEventHandler(this.controlAdded);
     this.BackColor       = Color.FromKnownColor(KnownColor.Window);
     this.Cursor          = Cursors.IBeam;
     this.AutoScroll      = true;
     this.AutoSize        = false;
     this.Padding         = new Padding(0, 0, 10, 0);
     this.WrapContents    = true;
     this.BorderStyle     = BorderStyle.FixedSingle;
     this.tb.KeyDown     += new System.Windows.Forms.KeyEventHandler(this.tb_KeyDown);
     this.tb.TextChanged += new EventHandler(this.tb_TextChanged);
     //Estilos del TextBox:
     this.tb.BackColor          = this.BackColor;
     this.tb.Width              = 15;
     this.tb.MinimumSize        = this.tb.Size;
     this.tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
     this.tb.AutoCompleteMode   = AutoCompleteMode.Suggest;
     this.tb.BorderStyle        = BorderStyle.None;
     this.tb.Values             = AutoCompleteList.ToArray();
     this.MouseEnter           += new EventHandler(this.OnMouseEnter);
     this.BackColorChanged     += new System.EventHandler(this.tb.tokenBox_BackColorChanged);
 }
        /// <summary>
        /// If text in control was changed
        /// </summary>
        /// <param name="value">Current text</param>
        private void Filter(string value)
        {
            if (value == "")
            {
                _currentTextHint = null;
                SetSuggestionsEmpty();
                return;
            }
            else
            {
                _currentTextHint = value;
            }

            if (_currentTextHint.Trim().Length < 2)
            {
                SetSuggestionsEmpty();
                return;
            }

            var list = AutoCompleteList.Where(i => (i ?? "").ToUpper().Contains(_currentTextHint.ToUpper()));

            if (list.Count() > 0)
            {
                AutoCompleteSuggestions = list.ToList();
            }
            else
            {
                SetSuggestionsEmpty();
            }
        }
Example #3
0
        private void PopulatingListShoppingList()
        {
            IAutocomplete autocomplete = new Autocomplete(_unit);

            AutoCompleteList?.Clear(); // not equal null
            foreach (var item in autocomplete.AutoCompleteProduct(ShoppingListItem))
            {
                AutoCompleteList?.Add(item);
            }
            OnPropertyChanged("AutoCompleteList");
        }
Example #4
0
        private void PopulatingListFindProduct()
        {
            IAutocomplete autocomplete = new Autocomplete(_unit);

            AutoCompleteList?.Clear();
            foreach (var item in autocomplete.AutoCompleteProduct(ProductName))
            {
                AutoCompleteList?.Add(item);
            }
            OnPropertyChanged("AutoCompleteList");
        }
Example #5
0
        public async Task AddAutoCompletes(AutoCompleteList autoCompleteList)
        {
            foreach (var item in autoCompleteList.Properties)
            {
                var record = await _context.AutoCompletes.Find(x => x.FormId == autoCompleteList.FormId && x.PropertyKey == item).FirstOrDefaultAsync();

                if (record == null)
                {
                    var id  = ObjectId.GenerateNewId().ToString();
                    var res = new AutoComplete {
                        Id = id, FormId = autoCompleteList.FormId, PropertyKey = item, Items = new List <string>()
                    };
                    await _context.AutoCompletes.InsertOneAsync(res);
                }
            }
        }
        // This is a timecritical part
        // Fills/ refreshed the CurrentAutoCompleteList with appropreate candidates
        private void UpdateCurrentAutoCompleteList()
        {
            // the list of suggestions has to be refreshed so clear it
            CurrentAutoCompleteList = AutoCompleteList.Copy();
            CurrentAutoCompleteList.Rows.Clear();
            // an find appropreate candidates for the new CurrentAutoCompleteList in AutoCompleteList
            foreach (DataRow row in AutoCompleteList.Rows)
            {
                if (SearchText(row, this.Text))
                {
                    CurrentAutoCompleteList.ImportRow(row);
                }
            }

            #region Excursus: Performance measuring of Linq queries

            // This is a simple example of speedmeasurement for Linq querries

            /*
             * CurrentAutoCompleteList.Clear();
             * Stopwatch stopWatch = new Stopwatch();
             * stopWatch.Start();
             * // using Linq query seems to be slower (twice as slow)
             * var query =
             *  from expression in this.AutoCompleteList
             *  where expression.ToLower().Contains(this.Text.ToLower())
             *  select expression;
             * foreach (string searchTerm in query)
             * {
             *  CurrentAutoCompleteList.Add(searchTerm);
             * }
             * stopWatch.Stop();
             * // method (see below) for printing the performance values to console
             * PrintStopwatch(stopWatch, "Linq - Contains");
             */

            #endregion Excursus: Performance measuring of Linq queries

            // countinue to update the ListBox - the visual part
            UpdateListBoxItems();
        }
        public async Task <ActionResult> AddAutoCompletes(string formId, [FromBody] AutoCompleteList autoCompleteList)
        {
            await _repo.AddAutoCompletes(autoCompleteList);

            return(NoContent());
        }
 public void AddItem(AutoCompleteEntry entry)
 {
     AutoCompleteList.Add(entry);
 }
Example #9
0
 internal void Initialize(AutoCompleteList autoComplete)
 {
     this.autoComplete = autoComplete;
     autoComplete.Initialize(this);
 }
        private void EnsureAutoCompleteListCreated()
        {
            if (null == autoCompleteList)
            {
                autoCompleteList = new AutoCompleteList();
                autoCompleteList.SetTextEditorControl(textEditorControl);
            }

            if (null == autoCompletePopup)
            {
                autoCompletePopup = new ExtensionPopup(this);
                autoCompletePopup.Child = autoCompleteList;
                autoCompletePopup.IsOpen = false;
            }
        }