示例#1
0
        /// <summary>
        /// Loads favorite phrases from the phrase list.
        /// </summary>
        private void loadPhrases()
        {
            var phrases = Phrases.Load();

            _phraseList = new List <Phrase>();

            foreach (var phrase in phrases.PhraseList)
            {
                if (phrase.Favorite)
                {
                    _phraseList.Add(phrase);
                }
            }

            for (int index = 1, phraseIndex = 0; phraseIndex < _phraseList.Count && index <= PhraseCount; index++)
            {
                String name = "Phrase" + index;

                var widget = _alphabetScannerCommon.PanelCommon.RootWidget.Finder.FindChild(name);
                if (widget != null)
                {
                    (widget as TabStopScannerButton).SetTabStops(0.0f, new float[] { 0 });
                    widget.SetText(_phraseList[phraseIndex].Text);
                    phraseIndex++;
                }
            }
        }
示例#2
0
文件: AppCommon.cs 项目: zezo010/acat
        /// <summary>
        /// Extracts speak abbreviations from the abbreviations
        /// file and adds them to the phrases file. Removes 'favorite'
        /// phrases from the abbreviations file.
        /// </summary>
        /// <param name="abbreviationsFile">input abbreviations file</param>
        /// <param name="phrasesFile">output phrases file</param>
        private static void extractPhrases(String abbreviationsFile, String phrasesFile)
        {
            var abbreviations = new Abbreviations();

            bool retVal = abbreviations.Load(abbreviationsFile);

            if (!abbreviations.AbbreviationList.Any() || !retVal)
            {
                return;
            }

            var phrases = File.Exists(phrasesFile) ? Phrases.Load(phrasesFile) : new Phrases();

            foreach (var abbreviation in abbreviations.AbbreviationList)
            {
                if (abbreviation.Mode == Abbreviation.AbbreviationMode.Speak && !String.IsNullOrEmpty(abbreviation.Expansion))
                {
                    var phrase = new Phrase {
                        Text = abbreviation.Expansion
                    };

                    if (abbreviation.Mnemonic.StartsWith("**"))
                    {
                        phrase.Favorite = true;
                    }

                    phrases.Add(phrase);
                }
            }

            phrases.Save(phrasesFile);

            var count = 0;

            while (true)
            {
                bool found = false;

                foreach (var abbreviation in abbreviations.AbbreviationList)
                {
                    if (abbreviation.Mnemonic.StartsWith("**"))
                    {
                        abbreviations.Remove(abbreviation.Mnemonic);
                        found = true;
                        count++;
                        break;
                    }
                }

                if (!found)
                {
                    if (count > 0)
                    {
                        abbreviations.Save(abbreviationsFile);
                    }

                    break;
                }
            }
        }
示例#3
0
        private void PhraseListEditForm_Load(object sender, EventArgs e)
        {
            float currentAspectRatio = (float)ClientSize.Height / ClientSize.Width;

            if (_designTimeAspectRatio != 0.0f && currentAspectRatio != _designTimeAspectRatio)
            {
                ClientSize = new System.Drawing.Size(ClientSize.Width, (int)(_designTimeAspectRatio * ClientSize.Width));
            }

            Text = R.GetString("EditPhrases");

            labelFavoritePhrase.Text = "* " + R.GetString("FavoritePhrase");

            _phrases = Phrases.Load();

            foreach (var phrase in _phrases.PhraseList)
            {
                phraseAdd(phrase);
            }

            listBoxPhrases.Focus();
            if (listBoxPhrases.Items.Count > 0)
            {
                listBoxPhrases.SelectedIndex = 0;
            }

            _windowActiveWatchdog = new WindowActiveWatchdog(this);

            _dialogCommon.OnLoad();

            PanelCommon.AnimationManager.Start(PanelCommon.RootWidget);
        }
示例#4
0
        /// <summary>
        /// Get the list of and populates the list
        /// </summary>
        public void LoadPhrases()
        {
            Windows.SetText(SearchFilter, String.Empty);

            var phrases = Phrases.Load();

            _allPhrasesList = phrases.PhraseList;

            _phrasesList = _allPhrasesList.ToList();

            refreshPhrasesList();
        }