private bool LoadLanguageToCombox()
        {
            bool _LoadLanguageNoError = false;
            TranslatorTextHelper _TranslatorTextHelper = new TranslatorTextHelper();

            try
            {
                AddLogTextLine(Properties.Resources.LoadLanguageToCombox);
                try
                {
                    _TranslatorTextHelper.PopulateLanguageMenus(cboSourceFilter);
                    CopyComboLanguage(cboSourceFilter, cboFromLanguage, false, cboSourceFilter.SelectedIndex);
                    CopyComboLanguage(cboSourceFilter, cboToLanguage, true, 0);
                    _LoadLanguageNoError = true;
                }
                finally
                {
                    ClearStatusText();
                }
            }
            catch (Exception e)
            {
                TranslatorTextHelper.LogExceptionError(e, AddLogText);
            }
            return(_LoadLanguageNoError);
        }
        private void SaveBingSpellCheckSettings()
        {
            TranslatorTextHelper _TranslatorTextHelper = new TranslatorTextHelper();

            _TranslatorTextHelper.BingSpellCheckUrl             = txtBingSpellCheckUrl.Text;
            _TranslatorTextHelper.BingSpellCheckSubscriptionKey = txtBingSpellCheckSubscriptionKey.Text;
            _TranslatorTextHelper.SaveBingSpellCheckSettings(chkSaveBingSpellCheckSubscriptionKey.Checked);
        }
        private void SaveTranslateAPISettings()
        {
            TranslatorTextHelper _TranslatorTextHelper = new TranslatorTextHelper();

            _TranslatorTextHelper.TranslateAPIBaseUrl      = txtTranslateAPIBaseUrl.Text;
            _TranslatorTextHelper.TranslateSubscriptionKey = txtTranslateSubscriptionKey.Text;
            _TranslatorTextHelper.SaveTranslateApiSettings(chkSaveTranlsateSubscriptionKey.Checked);
        }
        private void SaveProxySettings()
        {
            TranslatorTextHelper _TranslatorTextHelper = new TranslatorTextHelper();

            _TranslatorTextHelper.ProxyUrl      = txtProxyAddress.Text;
            _TranslatorTextHelper.ProxyUserName = txtProxyUserName.Text;
            _TranslatorTextHelper.ProxyPassword = txtProxyPassword.Text;
            if (string.IsNullOrWhiteSpace(txtProxyAddress.Text))
            {
                chkProxyUseDefaultCred.Checked = false;
            }
            _TranslatorTextHelper.ProxyUseDefaultCredentials = chkProxyUseDefaultCred.Checked;
            _TranslatorTextHelper.SaveProxySettings();
        }
        private void InitLoading()
        {
            pnlMain.Enabled = false;
            CheckDirSearch();
            startupTimer = new Timer {
                Interval = 1000
            };
            startupTimer.Tick += delegate
            {
                startupTimer.Enabled = false;
                Cursor = Cursors.WaitCursor;
                try
                {
                    pnlMain.Enabled = LoadLanguageToCombox();
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            };
            this.startupTimer.Start();

            TranslatorTextHelper _TranslatorTextHelper = new TranslatorTextHelper();

            txtTranslateAPIBaseUrl.Text             = _TranslatorTextHelper.TranslateAPIBaseUrl;
            txtTranslateSubscriptionKey.Text        = _TranslatorTextHelper.TranslateSubscriptionKey;
            chkSaveTranlsateSubscriptionKey.Checked = (!string.IsNullOrWhiteSpace(txtTranslateSubscriptionKey.Text));

            txtBingSpellCheckUrl.Text                    = _TranslatorTextHelper.BingSpellCheckUrl;
            txtBingSpellCheckSubscriptionKey.Text        = _TranslatorTextHelper.BingSpellCheckSubscriptionKey;
            chkSaveBingSpellCheckSubscriptionKey.Checked = (!string.IsNullOrWhiteSpace(txtBingSpellCheckSubscriptionKey.Text));
            chkBingSpellCheck.Enabled                    = (!string.IsNullOrWhiteSpace(txtBingSpellCheckSubscriptionKey.Text));

            txtProxyAddress.Text           = _TranslatorTextHelper.ProxyUrl;
            txtProxyUserName.Text          = _TranslatorTextHelper.ProxyUserName;
            txtProxyPassword.Text          = _TranslatorTextHelper.ProxyPassword;
            chkProxyUseDefaultCred.Checked = _TranslatorTextHelper.ProxyUseDefaultCredentials;
        }
        private void Translate()
        {
            dgvTo.Rows.Clear();
            Application.DoEvents();
            Cursor.Current = Cursors.WaitCursor;

            int _FileCount = 0;

            string _FileName        = string.Empty;
            string _FromLanguage    = GetLanguageTag(cboFromLanguage);
            string _FromCultureName = GetCultureName(cboFromLanguage);

            string _ToLanguage    = GetLanguageTag(cboToLanguage);
            string _ToCultureName = GetCultureName(cboToLanguage);

            _AbortRequested = false;

            AddLogTextLine(string.Empty);
            AddLogTextLine(string.Format(Properties.Resources.TranslateingStart, cboFromLanguage.Text, _FromCultureName,
                                         cboToLanguage.Text, _ToCultureName));

            TranslationResult    _TranslationResult    = new TranslationResult();
            TranslatorTextHelper _TranslatorTextHelper = new TranslatorTextHelper(_FromLanguage, _ToLanguage, _FromCultureName);

            _TranslatorTextHelper.TranslateAPIBaseUrl      = txtTranslateAPIBaseUrl.Text;
            _TranslatorTextHelper.TranslateSubscriptionKey = txtTranslateSubscriptionKey.Text;

            _TranslatorTextHelper.BingSpellCheckUrl             = txtBingSpellCheckUrl.Text;
            _TranslatorTextHelper.BingSpellCheckSubscriptionKey = txtBingSpellCheckSubscriptionKey.Text;

            _TranslatorTextHelper.ProxyUrl      = txtProxyAddress.Text;
            _TranslatorTextHelper.ProxyUserName = txtProxyUserName.Text;
            _TranslatorTextHelper.ProxyPassword = txtProxyPassword.Text;
            _TranslatorTextHelper.ProxyUseDefaultCredentials = chkProxyUseDefaultCred.Checked;

            foreach (DataGridViewRow _DataGridViewRow in dgvFrom.Rows)
            {
                if (!_FileName.Equals(_DataGridViewRow.Cells["FromFileName"].Value.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    _FileCount += 1;
                }

                _FileName           = _DataGridViewRow.Cells["FromFileName"].Value.ToString();
                _TranslationResult += _TranslatorTextHelper.Translation(
                    _FromCultureName, _ToCultureName,
                    chkBingSpellCheck.Checked,
                    _FileCount,
                    _DataGridViewRow, dgvTo,
                    AddLogText, () => _AbortRequested);
                SetStatusText(string.Format(Properties.Resources.TranslatingLineNo, _DataGridViewRow.Index, _FileCount));
                if (_AbortRequested)
                {
                    break;
                }
            }
            btnTranslate.Text = Properties.Resources.ButtonTranslate;
            if (!_AbortRequested)
            {
                AddLogTextLine(Properties.Resources.TranslateingEnd);
            }
            else
            {
                AddLogTextLine(Properties.Resources.TranslateingIncomplete);
            }
            ClearStatusText();
        }