Example #1
0
        /// <summary>
        /// Loads an epub file and analyse all the words
        /// </summary>
        /// <param name="path">The full path to the epub file</param>
        public void OpenEpub(string path)
        {
            // cancel any previous loading action and reset the grid and listbox
            grid.DataSource = null;
            lstOccurrences.Items.Clear();
            loader.CancelAll();

            // read the epub file structure
            Epub epub = Epub.FromFile(path);

            // change the caption of the form with the filename
            Text = "Epub spell checker - " + System.IO.Path.GetFileName(path);

            // analyse the epub async
            loader.LoadAsync <Dictionary <string, WordEntry> >((state) =>
            {
                // set progress to marquee
                state.Text     = "Loading epub...";
                state.Progress = -1;

                // get all the word entries in the book
                var wordEntries = manager.AnalyseEpub(epub);
                return(wordEntries);
            }, wes =>
            {
                // if there was a previously loaded epub, dispose it
                if (currentEpub != null)
                {
                    currentEpub.Dispose();
                }

                currentEpub = epub;

                // bind the word entry list to the datagridview
                var bs          = new SortableBindingList <WordEntry>(wes.Values);
                grid.DataSource = bs;

                // update the grid to match the current filter
                ApplyFilter(false);

                // update statistics of the word entry list
                UpdateStatistics();

                // continue with loading suggestions for each unknown word
                FillSuggestions(wes);

                CheckEditMenuItemAvailibility();
            });
        }