예제 #1
0
        /// <summary>
        /// Auto Translate The Selected Resource via Google Translator
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MenuItemClick(object sender, EventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;

            ContextMenu contextMenu = (ContextMenu)menuItem.Parent;


            TextBox            tbx = (TextBox)contextMenu.SourceControl;
            TextBoxTranslation tbt = (TextBoxTranslation)tbx.Tag;

            tbx.Text = Translator.TranslateText(tbx.Text, string.Format("{0}|{1}", sLangCodeSrc, sLangCodeDest));

            RangeRegion        region = grid1.Selection.GetSelectionRegion();
            PositionCollection poss   = region.GetCellsPositions();

            foreach (Position t in
                     from t in poss let cell = grid1.GetCell(t) as SourceGrid.Cells.Cell where cell != null select t)
            {
                GetCell(grid1, t).View = tbt.srcResourceValue.Equals(tbx.Text, StringComparison.OrdinalIgnoreCase) ? cellLocalResourceRed : cellLocalResource;
            }

            // Update Translations List
            translations.Find(check =>
                              check.sPageName.Equals(tbt.pageName) && check.sResourceName.Equals(tbt.resourceName)).
            sLocalizedValue = tbx.Text;

            // tlpTranslations.Focus();
        }
예제 #2
0
        /// <summary>
        /// Translate all Pending Ressources with Google Translator
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AutoTranslateAll(object sender, EventArgs e)
        {
            progressBar.Maximum = grid1.Rows.Count;
            progressBar.Minimum = 0;

            progressBar.Value = 0;

            Cursor = Cursors.WaitCursor;

            for (int i = 0; i < grid1.Rows.Count; i++)
            {
                progressBar.Value = i;

                if (grid1[i, 2].Editor == null)
                {
                    continue;
                }

                SourceGrid.Cells.Editors.TextBox tbx = (SourceGrid.Cells.Editors.TextBox)grid1[i, 2].Editor;

                TextBoxTranslation tbt = (TextBoxTranslation)tbx.Control.Tag;

                if (!tbx.Control.ForeColor.Equals(Color.Red))
                {
                    continue;
                }

                tbx.Control.Text = Translator.TranslateText(tbx.Control.Text,
                                                            string.Format("{0}|{1}", sLangCodeSrc, sLangCodeDest));

                tbx.Control.ForeColor = tbt.srcResourceValue.Equals(tbx.Control.Text, StringComparison.OrdinalIgnoreCase)
                                            ? Color.Red
                                            : Color.Black;

                // Update Translations List
                translations.Find(check =>
                                  check.sPageName.Equals(tbt.pageName) &&
                                  check.sResourceName.Equals(tbt.resourceName)).
                sLocalizedValue = tbx.Control.Text;


                grid1[i, 2].View = tbt.srcResourceValue.Equals(tbx.Control.Text, StringComparison.OrdinalIgnoreCase)
                                       ? cellLocalResourceRed
                                       : cellLocalResource;

                grid1[i, 2].Value = tbx.Control.Text;
            }

            grid1.Update();


            Cursor = Cursors.Default;
        }
예제 #3
0
        /// <summary>
        /// Compare source and destination values on focus lost and indicate (guess) whether text is translated or not
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void TbxLostFocus(object sender, EventArgs e)
        {
            TextBox            tbx = (TextBox)sender;
            TextBoxTranslation tbt = (TextBoxTranslation)tbx.Tag;


            tbx.ForeColor = tbt.srcResourceValue.Equals(tbx.Text, StringComparison.OrdinalIgnoreCase) ? Color.Red : Color.Black;

            RangeRegion        region = grid1.Selection.GetSelectionRegion();
            PositionCollection poss   = region.GetCellsPositions();

            foreach (Position t in
                     from t in poss let cell = grid1.GetCell(t) as SourceGrid.Cells.Cell where cell != null select t)
            {
                GetCell(grid1, t).View = tbt.srcResourceValue.Equals(tbx.Text, StringComparison.OrdinalIgnoreCase) ? cellLocalResourceRed : cellLocalResource;
            }

            // Update Translations List
            translations.Find(check =>
                              check.sPageName.Equals(tbt.pageName) && check.sResourceName.Equals(tbt.resourceName)).
            sLocalizedValue = tbx.Text;

            //tlpTranslations.Focus();
        }