ACAT.Extensions.Default.FunctionalAgents.AbbreviationsAgent.AbbreviationsScanner.refreshAbbreviationsList C# (CSharp) Method

refreshAbbreviationsList() private method

Refreshes the list of abbreviations and displays the current pageful of abbreviations in the UI.
private refreshAbbreviationsList ( ) : void
return void
        private void refreshAbbreviationsList()
        {
            var list = new List<Widget>();
            _scannerCommon.GetRootWidget().Finder.FindChild(typeof(TabStopScannerButton), list);

            int count = list.Count();
            if (count == 0)
            {
                return;
            }

            foreach (var button in list)
            {
                button.UserData = null;
                button.SetText(String.Empty);
            }

            _entriesPerPage = count;
            _numPages = _abbreviationsList.Count() / _entriesPerPage;

            if ((_abbreviationsList.Count() % _entriesPerPage) != 0)
            {
                _numPages++;
            }

            updateButtonBar();

            updateStatusBar();

            if (!_abbreviationsList.Any())
            {
                (list[0] as TabStopScannerButton).SetTabStops(0.0f, new float[] { 100, 120 });
                list[0].SetText(Resources._TABBREVIATIONSLISTEMPTY);
                return;
            }

            _abbreviationsList = sort(_abbreviationsList, _sortOrder);

            int ii = 0;

            for (int jj = _pageStartIndex; jj < _abbreviationsList.Count && ii < count; ii++, jj++)
            {
                (list[ii] as TabStopScannerButton).SetTabStops(0.0f, new float[] { 100, 120 });

                list[ii].UserData = _abbreviationsList[jj];

                var word = _abbreviationsList[jj].Mnemonic;
                if (word.Length > MaxAbbrCharacters)
                {
                    word = word.Substring(0, MaxAbbrCharacters) + "...";
                }

                var replaceWith = System.Text.RegularExpressions.Regex.Replace(_abbreviationsList[jj].Expansion, "\n", " ");
                if (replaceWith.Length > 40)
                {
                    replaceWith = replaceWith.Substring(0, 40) + "...";
                }

                list[ii].SetText(word + "\t" + _abbreviationsList[jj].Mode + "\t" + replaceWith);
            }
        }