Contains the logic for calculating the frequency of each word in the document. This class should be run using a BackgroundWorker object, which is then passed in as a parameter in the constructor.
Пример #1
0
        /// <summary>
        /// Starts the calculation of word frequencies by getting an array of all words in the current document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;

            //Select the range as the entire document.
            object start = 0;
            object end   = app.ActiveDocument.Characters.Count;

            Microsoft.Office.Interop.Word.Range rng = app.ActiveDocument.Range(ref start, ref end);

            Words words = app.ActiveDocument.Words;

            this.wordcount = app.ActiveDocument.Words.Count;

            //TODO - parellilize this with multiple background workers. here or in the ribbon class?
            FrequencyCalculation m = new FrequencyCalculation(bgWorker, words, 1, wordcount, (bool)e.Argument);

            e.Result = m.getResult();
        }
        /// <summary>
        /// Starts the calculation of word frequencies by getting an array of all words in the current document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;

            //Select the range as the entire document.
            object start = 0;
            object end = app.ActiveDocument.Characters.Count;
            Microsoft.Office.Interop.Word.Range rng = app.ActiveDocument.Range(ref start, ref end);

            Words words = app.ActiveDocument.Words;
            this.wordcount = app.ActiveDocument.Words.Count;

            //TODO - parellilize this with multiple background workers. here or in the ribbon class?
            FrequencyCalculation m = new FrequencyCalculation(bgWorker, words, 1, wordcount, (bool)e.Argument);
            e.Result = m.getResult();
        }