コード例 #1
0
ファイル: FrmMain.cs プロジェクト: xtoik/AcroniManager
        private object replaceAcronyms(FrmWait frmWait, object objInputText)
        {
            string ret = null;

            frmWait.SetupProgressBar(_acronyms.Count);
            _acronyms.Reverse();
            string        originalText    = objInputText as string;
            StringBuilder text            = new StringBuilder(objInputText as string);
            int           acronymsTreated = 0;

            foreach (FoundAcronym acronym in _acronyms)
            {
                SelectedMeaningBase meaning;
                if (acronym.IsMeaningSet)
                {
                    meaning = acronym.Meaning;
                }
                else
                {
                    meaning = _acroInquisitor.GetAcronymMeaning(acronym, originalText);
                }

                if (meaning != null)
                {
                    text.Remove(acronym.Index, acronym.Caption.Length);
                    text.Insert(acronym.Index, meaning);
                }
                frmWait.UpdateProgressBar(++acronymsTreated);
            }
            ret = text.ToString();

            return(ret);
        }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: xtoik/AcroniManager
 private void btnReplaceAll_Click(object sender, EventArgs e)
 {
     if (_acronyms != null)
     {
         try
         {
             Cursor.Current = Cursors.WaitCursor;
             _updatingText  = true;
             using (FrmWait frmWait = new FrmWait {
                 Text = "Replacing acronyms..."
             })
             {
                 frmWait.AsyncProcess   = replaceAcronyms;
                 frmWait.InputParameter = rtxtInput.Text;
                 frmWait.ShowDialog(this);
                 if (frmWait.HasFailed)
                 {
                     MessageBox.Show("Exception occurred: " + frmWait.ThrownException.ToString());
                 }
                 else
                 {
                     rtxtInput.Text = frmWait.OutputParameter as string;
                     highlightAcronyms(_acronymUnknownColor);
                 }
             }
         }
         finally
         {
             _updatingText  = false;
             Cursor.Current = Cursors.Default;
             rtxtInput.Select();
         }
     }
 }