Example #1
0
        private void formReading_Load(object sender, EventArgs e)
        {
            //icon
            string iconPath = Application.StartupPath + "\\Wordy.ico";

            if (File.Exists(iconPath))
                this.Icon = new Icon(iconPath);

            //set back colors
            this.BackColor = Color.FromArgb(211, 211, 211);
            rtbText.BackColor = this.BackColor;

            //load/init arrays & stuff
            corewords = Misc.LoadCoreWords();
            loadNewwords();

            wordnik = new WordnikService("b3bbd1f9103a01de7d00a0fd1300164c17bfcec03eb86a678");

            newDefs = new Dictionary<string, Definition>(StringComparer.OrdinalIgnoreCase);
            synonyms = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            rhymes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

            searchedWords = new List<string>();
            notFoundWords = new List<string>();

            ActiveSearchWord = "";
            ActiveGooglingWord = "";
            rtbTextVScroll = 0;
            colorizing = false;
            UsePrevPopupPos = false;

            Gfx = this.CreateGraphics();
            MeasuringStringFormat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces);
            LineH = Gfx.MeasureString("A", rtbText.Font, int.MaxValue, MeasuringStringFormat).Height;

            //prepare popup window
            popup = new formPopup();

            popup.main = main;
            popup.reading = this;
            popup.Left = -1000; //hide popup
            popup.Show();

            //prepare language tools
            if (main.Profile == "English")
            {
                SearchWordWorker = new BackgroundWorker();
                SearchWordWorker.DoWork += new DoWorkEventHandler(searchWordWorker_DoWork);
                SearchWordWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(searchWordWorker_RunWorkerCompleted);
            }
            else
                Translator = new Translator(main.Languages[main.Profile], "en", doneEvent, main.prefs);
        }
Example #2
0
        bool getExampleSentences()
        {
            try
            {
                if (wordnik == null)
                    wordnik = new WordnikService("b3bbd1f9103a01de7d00a0fd1300164c17bfcec03eb86a678");
                var exampleResults = wordnik.GetExamples(testWord.ToString());

                if (exampleResults.Examples == null)
                    return false;

                var examples = exampleResults.Examples.ToArray();
                exampleSentences = new string[examples.Length];

                for (int i = 0; i < examples.Length; i++)
                    exampleSentences[i] = removeWordInstances(examples[i].Text, testWord.ToString());

                lblDef.Text = exampleSentences[rand.Next(examples.Length)];

                return true;
            }
            catch
            {
                return false;
            }
        }