public void persistModel()
        {
            String engine = "MYMEMORY";

            if (model.getEngine().Equals(TranslateSettingsModel.Engine.BING))
            {
                engine = "BING";
            }

            Win32.WritePrivateProfileString("ENGINE", "engine", engine, dataSourcePath);

            Win32.WritePrivateProfileString("MYMEMORY", "email", model.email, dataSourcePath);

            Win32.WritePrivateProfileString("BING", "ClientIDAndSecret", model.getClientCredentials().First + ";" + model.getClientCredentials().Second, dataSourcePath);

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

            foreach (Pair codeNamePair in model.getAllLanguages())
            {
                writableStringList.Add(codeNamePair.First + ":" + codeNamePair.Second);
            }

            string writableString = string.Join(";", writableStringList.ToArray());

            Win32.WritePrivateProfileString("TRANSLATE", "ALLLANGUAGES", writableString, dataSourcePath);

            string langPrefStr = model.getLanguagePreference().First + ":" + model.getLanguagePreference().Second;

            Win32.WritePrivateProfileString("TRANSLATE", "LANGUAGEPREF", langPrefStr, dataSourcePath);
        }
Ejemplo n.º 2
0
        private void updateEngineBasedOnPreference()
        {
            switch (settings.getEngine())
            {
            case TranslateSettingsModel.Engine.MYMEMORY:
                engine = new MyMemoryTranslateEngine(settings);
                break;

            case TranslateSettingsModel.Engine.BING:
                engine = new BINGTranslateEngine(settings);
                break;
            }

            Util.writeInfoLog("Current Engine: " + engine.ToString());
        }
Ejemplo n.º 3
0
        internal static void showTranslationResults(string from, string to, string transResult)
        {
            Util.BEGINFUN("showTranslationResults");

            try
            {
                StringBuilder transDisplay = new StringBuilder();
                transDisplay.Append(from);
                transDisplay.Append(" ==> ");
                transDisplay.Append(to);

                transDisplay.Append("\n\n**********************************************************\n\n");

                transDisplay.Append(transResult);

                transDisplay.Append("\n\n**********************************************************\n\n");

                transDisplay.Append("Do you want to copy translated text to clipboard?\n");

                DialogResult selection = MessageBox.Show(System.Windows.Forms.Control.FromHandle(GetCurrentEditHandle()), transDisplay.ToString(), "Translation Result, powered by " + trSettingsModel.getEngine().ToString(), MessageBoxButtons.YesNo);
                if (selection.Equals(DialogResult.Yes))
                {
                    CopyTranslatedTextDataToClipBoard(transResult);
                }
            }
            catch (Exception ex)
            {
                handleException(ex);
            }
            Util.ENDFUN("showTranslationResults");
        }