Пример #1
0
        private void materialRaisedButton1_Click_1(object sender, EventArgs e)
        {
            MessageBox.Show("Open a new instance of your browser!");
            List <string> list = new List <string>();

            list = MiscFunctions.GatherWords(inputTextBox.Text);
            if (File.Exists(inputTextBox.Text))
            {
                if (list.Count == 0)
                {
                    MessageBox.Show("Words list is empty!");
                }
                else
                {
                    foreach (var item in list)
                    {
                        Process.Start("https://translate.google.com/#view=home&op=translate&sl=en&tl=sl&text=" + item);
                    }
                }
            }
        }
Пример #2
0
        private void compileBtn_Click(object sender, EventArgs e)
        {
            if (apiKeyTextBox.Text == "Please select or write an api key")
            {
                MessageBox.Show("Please enter a valid api key!");
            }
            else
            {
                sw.Start();
                dic.Clear();
                PathIn      = inputTextBox.Text;
                ApiKeyConst = apiKeyTextBox.Text;

                includeStatus.CountCheck    = false;
                includeStatus.OrderCheck    = false;
                includeStatus.EngWordsCheck = false;
                includeStatus.SloWordsCheck = false;
                includeStatus.MeaningCheck  = false;
                includeStatus.PronCheck     = false;
                includeStatus.UrlCheck      = false;

                if (countCheck.Checked == true)
                {
                    includeStatus.CountCheck = true;
                }
                if (orderCheck.Checked == true)
                {
                    includeStatus.OrderCheck = true;
                }
                if (engWordsCheck.Checked == true)
                {
                    includeStatus.EngWordsCheck = true;
                }
                if (sloWordsCheck.Checked == true)
                {
                    includeStatus.SloWordsCheck = true;
                }
                if (meaningCheck.Checked == true)
                {
                    includeStatus.MeaningCheck = true;
                }
                if (pronCheck.Checked == true)
                {
                    includeStatus.PronCheck = true;
                }
                if (urlCheck.Checked == true)
                {
                    includeStatus.UrlCheck = true;
                }

                try
                {
                    List <string> progressLenghtCheck = MiscFunctions.GatherWords(PathIn);
                    progressBar.Maximum         = progressLenghtCheck.Count();
                    progressBar.SuperscriptText = "/" + progressLenghtCheck.Count();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + " (GetProgressBarLength.0)");
                }

                BackgroundWorker worker = new BackgroundWorker();

                if (engWordsCheck.Checked == false && sloWordsCheck.Checked == false && meaningCheck.Checked == false && pronCheck.Checked == false && urlCheck.Checked == false)
                {
                    MessageBox.Show("No include option checked! Do so at setting tab!");
                    //TimerLabel.Content = "Took: --- ms";
                    //ItemsCountLabel.Content = "composed: --- words";
                    //ListOutput.Items.Add("You must select at least one include checkbox!");
                }
                else
                {
                    materialTabControl1.SelectTab("tabPage2");
                    worker.RunWorkerCompleted   += Worker_RunWorkerCompleted;
                    worker.WorkerReportsProgress = true;
                    worker.DoWork          += Worker_DoWork;
                    worker.ProgressChanged += Worker_ProgressChanged;
                    worker.RunWorkerAsync();
                }
            }
        }
Пример #3
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            fail = false;
            var worker = sender as BackgroundWorker;

            worker.ReportProgress(0);

            List <string> list = new List <string>();

            try
            {
                list = MiscFunctions.GatherWords(PathIn);
                if (includeStatus.OrderCheck)
                {
                    list.Sort();
                }
                try
                {
                    Word word;
                    int  count = 0;
                    foreach (var item in list)
                    {
                        count++;
                        word = new Word();

                        if (includeStatus.CountCheck)
                        {
                            word.WordCount = count + ";";
                        }
                        if (includeStatus.EngWordsCheck)
                        {
                            word.EngWord = item + ";";
                        }
                        if (includeStatus.SloWordsCheck)
                        {
                            word.SloWord = Translation.TranslateAsync(item, ApiKeyConst, langTextBox.Text) + ";";
                        }
                        if (includeStatus.MeaningCheck)
                        {
                            word.Meaning = "Meaning" + ";";
                        }
                        if (includeStatus.PronCheck)
                        {
                            word.Pron = "Pronunciation" + ";";
                        }
                        if (includeStatus.UrlCheck)
                        {
                            string tempUrl = string.Format("https://www.google.com/search?q={0}&tbm=isch&q=", item);
                            word.UrlText = tempUrl;
                        }
                        dic.Add(word.ConcatenateProperties());
                        worker.ReportProgress(count);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "(compileScript.1)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    fail = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "(compileScript.0)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                fail = true;
            }
        }