void BChangeNameClick(object sender, EventArgs e)
        {
            ListViewItem         lvi = lvProfiles.SelectedItems[0];
            UserTranslateProfile pf  = lvi.Tag as UserTranslateProfile;

            string             oldName  = pf.Name;
            SetProfileNameForm nameForm = new SetProfileNameForm(pf as UserTranslateProfile, profiles);

            DialogResult dr = nameForm.ShowDialog(FindForm());

            nameForm.Dispose();
            if (dr == DialogResult.Cancel)
            {
                pf.Name = oldName;
                return;
            }
            else
            {
                profilesHistory.RenameProfile(oldName, pf.Name);
            }


            lvi.Text          = pf.Name;
            lProfileName.Text = pf.Name;

            lvi.SubItems[1].Text = (LangPack.TranslateLanguage(pf.TranslationDirection.From) +
                                    " -> " +
                                    LangPack.TranslateLanguage(pf.TranslationDirection.To)
                                    );
            lvi.SubItems[2].Text = LangPack.TranslateString(pf.Subject);


            LvProfilesSelectedIndexChanged(lvProfiles, new EventArgs());
        }
Esempio n. 2
0
        public void SetEndData(AsyncTranslateState state)
        {
            bool nothingFound = true;

            foreach (Result r in state.Results)
            {
                if (!r.ResultNotFound)
                {
                    nothingFound = false;
                    break;
                }
            }
            string htmlString;

            if (nothingFound && TranslateOptions.Instance.ResultWindowOptions.HideWithoutResult)
            {
                htmlString = "<span><br/>" + LangPack.TranslateString("Nothing found") + "<br/></span>";

                Wait();
                HtmlHelper.AddTranslationCell(wBrowser, isClean, htmlString);
            }

            isClean = false;

            //force set of proper size - some time don't show bottom lines
            Size sz = wBrowser.Size;

            sz.Height++;
            wBrowser.Size = sz;
            RealRecalcSizes();
            sz.Height--;
            wBrowser.Size = sz;
            RealRecalcSizes();
        }
Esempio n. 3
0
        static void DownloadVersionsCompleted(Object sender, DownloadStringCompletedEventArgs e)
        {
            WebClient client = sender as WebClient;

            if (state == UpdateState.Cancel)
            {
                Cancelled();
                return;
            }

            if (e.Cancelled || e.Error != null)
            {
                string url = Constants.VersionsTxtUrls[versionUrlToCheck];
                if (TryToRerunVersionsCheck(client))
                {
                    return;
                }

                if (e.Error != null)
                {
                    SetErrorState(string.Format(CultureInfo.InvariantCulture, LangPack.TranslateString("Error on downloading {0}"), url) + "\r\n" + e.Error.Message);
                }
                else
                {
                    SetErrorState(LangPack.TranslateString("Canceled"));
                }
                return;
            }


            //versions.txt received, next step
            ParseVersions(client, e.Result);
        }
Esempio n. 4
0
        public static GuessResult Guess(string phrase, NetworkSetting networkSetting, EventHandler <GuessCompletedEventArgs> guessCompletedHandler)
        {
            AsyncGuessState state = null;
            bool            done  = false;
            EventHandler <GuessCompletedEventArgs> myHandler = delegate(object sender, GuessCompletedEventArgs e)
            {
                try
                {
                    FreeCL.Forms.Application.EndGuiLockingTask();
                    if (guessCompletedHandler != null)
                    {
                        guessCompletedHandler.Invoke(state, e);
                    }
                }
                finally
                {
                    done = true;
                }
            };

            FreeCL.Forms.Application.StartGuiLockingTask(LangPack.TranslateString("Language detection"));
            state = GuessAsync(phrase, networkSetting, myHandler);

            while (!done)
            {
                System.Windows.Forms.Application.DoEvents();
                Thread.Sleep(50);
            }
            return(state.Result);
        }
Esempio n. 5
0
        void OnLanguageChanged()
        {
            ignoreServicesLoading = true;
            try
            {
                if (languages != null)
                {
                    LoadLanguages();
                    LoadSubjects();
                    LoadHistory();
                }
                tpLangs.Text                = LangPack.TranslateString("Languages");
                tpSubject.Text              = LangPack.TranslateString("Subjects");
                tpServices.Text             = LangPack.TranslateString("Services");
                lEnabled.Text               = LangPack.TranslateString("Enabled");
                lDisabled.Text              = LangPack.TranslateString("Error");
                lDisabledByUser.Text        = LangPack.TranslateString("Disabled");
                miMoveServiceUp.Text        = LangPack.TranslateString("Move service up");
                miMoveServiceUp.ToolTipText = miMoveServiceUp.Text;
                ttMain.SetToolTip(sbServiceUp, miMoveServiceUp.Text);

                miMoveServiceDown.Text        = LangPack.TranslateString("Move service down");
                miMoveServiceDown.ToolTipText = miMoveServiceDown.Text;
                ttMain.SetToolTip(sbServiceDown, miMoveServiceDown.Text);
                //TODO:ttMain.SetToolTip(sbEnableService, LangPack.TranslateString(""));


                LvServicesResize(this, new EventArgs());
            }
            finally
            {
                ignoreServicesLoading = false;
                LoadServices(false);
            }
        }
Esempio n. 6
0
        void LoadSubjects()
        {
            lbSubjects.BeginUpdate();
            loadingSubjects = true;
            lbSubjects.Items.Clear();
            string val;

            val = "+ " + LangPack.TranslateString("Toggle all");
            lbSubjects.Items.Add(new SubjectContainer("Toggle all", val));

            foreach (string s in supportedSubjects)
            {
                val = LangPack.TranslateString(s);
                if (s == "Common")
                {
                    val = "+" + val;
                }
                lbSubjects.Items.Add(new SubjectContainer(s, val), subjects.Contains(s));
            }
            lbSubjects.EndUpdate();
            lbSubjects.SetItemChecked(0, lbSubjects.CheckedItems.Count == supportedSubjects.Count);
            loadingSubjects      = false;
            serviceItemsSettings = null;             //reset
            LoadServices(false);
        }
 public HotkeyData(Keys keys, MouseButtons mouseButtons, bool custom)
 {
     this.keys         = keys;
     this.mouseButtons = mouseButtons;
     this.name         = HotkeysOptionsControl.GetHotkeyName(keys, mouseButtons, custom);
     this.caption      = LangPack.TranslateString(name);
 }
        void CbSubjectSelectedIndexChanged(object sender, EventArgs e)
        {
            if (ignoreLanguageChange)
            {
                return;
            }

            if (lvProfiles.SelectedItems.Count != 1)
            {
                return;
            }

            ListViewItem         lvi = lvProfiles.SelectedItems[0];
            UserTranslateProfile pf  = lvi.Tag as UserTranslateProfile;

            if (pf == null)
            {
                return;
            }

            SubjectContainer sc = cbSubject.SelectedItem as SubjectContainer;

            pf.Subject = sc.Subject;

            lvi.SubItems[2].Text = LangPack.TranslateString(sc.Subject);
        }
        void CbToSelectedIndexChanged(object sender, EventArgs e)
        {
            if (ignoreLanguageChange)
            {
                return;
            }

            if (lvProfiles.SelectedItems.Count != 1)
            {
                return;
            }

            ListViewItem         lvi = lvProfiles.SelectedItems[0];
            UserTranslateProfile pf  = lvi.Tag as UserTranslateProfile;

            if (pf == null)
            {
                return;
            }

            LanguageDataContainer ld = cbTo.SelectedItem as LanguageDataContainer;

            pf.TranslationDirection.To = ld.Language;

            lvi.SubItems[1].Text = (LangPack.TranslateLanguage(pf.TranslationDirection.From) +
                                    " -> " +
                                    LangPack.TranslateLanguage(pf.TranslationDirection.To)
                                    );
        }
Esempio n. 10
0
        public void ShowSource()
        {
            Wait();
            string clean   = wBrowser.DocumentText;
            int    bodyidx = clean.IndexOf("<body>");

            if (bodyidx < 0)
            {
                bodyidx = clean.IndexOf("<BODY>");
            }

            if (bodyidx < 0)
            {
                MessageBox.Show(FindForm(),
                                LangPack.TranslateString("Nothing found"),
                                Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            clean = clean.Substring(0, bodyidx);
            HtmlSourceViewForm form = new HtmlSourceViewForm();

            form.Source = clean + WebBrowserHelper.GetDocument(wBrowser).Body.OuterHtml + "\r\n</html>";
            form.Text   = wBrowser.Url.ToString();
            form.Show();
        }
        void InitUserProfileControls()
        {
            cbFrom.Items.Clear();
            cbTo.Items.Clear();

            for (int i = 0; i < (int)Language.Last; i++)
            {
                LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i));
                cbFrom.Items.Add(ld);
                cbTo.Items.Add(ld);
            }

            cbSubject.Items.Clear();
            foreach (string subject in Manager.Subjects)
            {
                SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject));
                cbSubject.Items.Add(sc);
            }

            SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, LangPack.TranslateString(SubjectConstants.Any));

            cbSubject.Items.Add(sc1);

            changed = false;
            LvProfilesSelectedIndexChanged(lvProfiles, new EventArgs());
        }
        void LoadLangToLayout()
        {
            DataTable dtLangs = dsMain.Tables["LangToLayouts"];

            if (dtLangs.Rows.Count == 0)
            {
                for (int i = 1; i < (int)Language.Last; i++)
                {
                    Language lng = (Language)i;
                    if (lng == Language.Autodetect)
                    {
                        continue;
                    }

                    DataRow row = dtLangs.NewRow();
                    row["Language"]    = lng;
                    row["DisplayName"] = LangPack.TranslateLanguage(lng);
                    row["Layout"]      = dontchangeStr;
                    dtLangs.Rows.Add(row);
                }
            }
            else
            {
                for (int i = 1; i < (int)Language.Last; i++)
                {
                    Language lng = (Language)i;
                    if (lng == Language.Autodetect)
                    {
                        continue;
                    }

                    DataRow row = dtLangs.Rows.Find(lng);
                    row["DisplayName"] = LangPack.TranslateLanguage(lng);
                }
            }

            string tooltip;

            foreach (DataGridViewRow gvRow in dgvLayouts.Rows)
            {
                DataRowView rowView = gvRow.DataBoundItem as DataRowView;
                DataRow     row     = rowView.Row;

                if (row.IsNull("SavedLayout"))
                {
                    break;
                }
                row["Changed"]          = String.Compare((string)row["Layout"], (string)row["SavedLayout"], false, CultureInfo.InvariantCulture) != 0;
                row["Auto"]             = String.Compare((string)row["Layout"], (string)row["AutoLayout"], false, CultureInfo.InvariantCulture) == 0;
                gvRow.Cells[2].ReadOnly = (bool)row["Auto"];
                gvRow.Cells[3].ReadOnly = !(bool)row["Changed"];

                tooltip = GenerateTooltip(row);
                for (int i = 0; i < 4; i++)
                {
                    gvRow.Cells[i].ToolTipText = tooltip;
                }
            }
        }
Esempio n. 13
0
 static void Cancelled()
 {
     message           = LangPack.TranslateString("Canceled");
     state             = UpdateState.None;
     versionUrlToCheck = 0;
     TranslateOptions.Instance.UpdateOptions.NextCheck       = new DateTime(DateTime.Now.Ticks + DateTimeUtils.Days(1).Ticks);       //next day
     TranslateOptions.Instance.UpdateOptions.LastCheckResult = message;
     TranslateOptions.Instance.UpdateOptions.LastCheck       = DateTime.Now;
 }
        void OnLanguageChanged()
        {
            aMoveProfileUp.Hint   = TranslateString("Move profile up");
            aMoveProfileDown.Hint = TranslateString("Move profile down");
            chName.Text           = TranslateString("Name");
            chDirection.Text      = TranslateString("Translation direction");
            chSubject.Text        = TranslateString("Subject");
            lName.Text            = TranslateString("Name");
            cbIncludeMonolingualDictionaryInTranslation.Text = TranslateString("Include monolingual dictionaries in translation");
            aAddProfile.Hint      = TranslateString("Add new user profile");
            aRemoveProfile.Hint   = TranslateString("Remove user profile");
            tpDefaultOptions.Text = TranslateString("Options");
            tpOptions.Text        = TranslateString("Options");
            tpServices.Text       = TranslateString("Services");
            bChangeName.Text      = TranslateString("Set profile properties");
            lLangPair.Text        = TranslateString("Translation direction");
            lSubject.Text         = TranslateString("Subject");

            aEditServices.Hint    = TranslateString("Edit services");
            aRemoveService.Hint   = TranslateString("Remove service");
            aMoveServiceUp.Hint   = TranslateString("Move service up");
            aMoveServiceDown.Hint = TranslateString("Move service down");


            tpLanguageSelector.Text = TranslateString("View");
            cbShowServices.Text     = TranslateString("Show services list");
            cbShowLanguages.Text    = TranslateString("Show languages list");
            cbShowSubjects.Text     = TranslateString("Show subjects list");

            bLanguageFilter.Text = TranslateString("Filter of languages");

            foreach (ListViewItem lvi in lvProfiles.Items)
            {
                if (lvi.Tag == defaultProfile)
                {
                    lvi.Text = TranslateString(TranslateOptions.Instance.DefaultProfile.Name);
                }
                else
                {
                    UserTranslateProfile pf = lvi.Tag as UserTranslateProfile;
                    if (pf != null)
                    {
                        lvi.SubItems[1].Text = (LangPack.TranslateLanguage(pf.TranslationDirection.From) +
                                                " -> " +
                                                LangPack.TranslateLanguage(pf.TranslationDirection.To)
                                                );
                        lvi.SubItems[2].Text = LangPack.TranslateString(pf.Subject);
                    }
                }
            }


            chDirection.Width = -2;
            chSubject.Width   = -2;

            InitUserProfileControls();
        }
        public static string GetShortNameOfTranslateDirection(LanguagePair languagePair)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(StringParser.SafeResizeString(LangPack.TranslateLanguage(languagePair.From), 3));
            sb.Append("->");
            sb.Append(StringParser.SafeResizeString(LangPack.TranslateLanguage(languagePair.To), 3));

            return(sb.ToString());
        }
Esempio n. 16
0
        void OnLanguageChanged()
        {
            bOk.Text       = TranslateString("OK");
            bCancel.Text   = LangPack.TranslateString("Cancel");
            lName.Text     = LangPack.TranslateString("Profile name");
            lLangPair.Text = TranslateString("Translation direction");
            lSubject.Text  = TranslateString("Subject");

            Text = LangPack.TranslateString("Set profile properties");
        }
Esempio n. 17
0
 void OnLanguageChanged()
 {
     lName.Text    = LangPack.TranslateString("Name") + " :";
     lSize.Text    = LangPack.TranslateString("Size") + " :";
     cbSystem.Text = LangPack.TranslateString("Default font");
     toolTip.SetToolTip(cbSystem,
                        LangPack.TranslateString("Name") + " :" + defaultFont.Name + ", " +
                        LangPack.TranslateString("Size") + " :" + defaultFont.Size.ToString()
                        );
 }
Esempio n. 18
0
        void AboutFormVisibleChanged(object sender, EventArgs e)
        {
            lStats.Text = string.Format(
                TranslateString("{0} phrases translated by {1} calls to translate services"),
                TranslateOptions.Instance.StatOptions.Calls,
                TranslateOptions.Instance.StatOptions.ServiceCalls
                );

            Text            = LangPack.TranslateString("About") + " " + lAppTitle.Text;
            bDonate.Text    = LangPack.TranslateString("Donate ...");
            bDonate.Visible = !(FreeCL.RTL.LangPack.CurrentLanguage == "Russian" || FreeCL.RTL.LangPack.CurrentLanguage == "Ukrainian");
        }
Esempio n. 19
0
        void LvServicesEnabledSelectedIndexChanged(object sender, EventArgs e)
        {
            LockUpdate(true);
            try
            {
                if (skipselectingservices)
                {
                    return;
                }
                ListView lv = sender as ListView;
                if (lv.SelectedItems.Count == 0)
                {
                    return;
                }

                ListViewItem             lvi = lv.SelectedItems[0];
                ServiceSettingsContainer sc  = lvi.Tag as ServiceSettingsContainer;
                serviceStatus.ShowLanguage = selection.From == Language.Any || selection.To == Language.Any;
                serviceStatus.Status       = sc;

                if (sc.DisabledByUser)
                {
                    sbEnableService.Text = LangPack.TranslateString("Enable");
                }
                else
                {
                    sbEnableService.Text = LangPack.TranslateString("Disable");
                }
                miEnableService.Text = sbEnableService.Text;
                //ttMain.SetToolTip(sbEnableService, sbEnableService.Text);

                if ((lvServicesEnabled == lv || lv == lvServicesDisabled) &&
                    lv.Items.Count > 1 &&
                    (selection.From != Language.Any && selection.To != Language.Any))
                {
                    sbServiceUp.Enabled   = lv.SelectedIndices[0] != 0;
                    sbServiceDown.Enabled = lv.SelectedIndices[0] != lv.Items.Count - 1;
                }
                else
                {
                    sbServiceUp.Enabled   = false;
                    sbServiceDown.Enabled = false;
                }

                miMoveServiceDown.Enabled = sbServiceDown.Enabled;
                miMoveServiceUp.Enabled   = sbServiceUp.Enabled;
            }
            finally
            {
                LockUpdate(false);
            }
        }
Esempio n. 20
0
 void OnLanguageChanged()
 {
     Text = TranslateString("Usage information collecting");
     bYes.Text = TranslateString("Yes");
     bNo.Text = LangPack.TranslateString("Cancel");
     lTop.Text = TranslateString("Do you want to allow collecting of basic information about application usage ?");
     gbWill.Text = TranslateString("Tool will");
     gbWillNot.Text = TranslateString("Tool will not");
     lWill.Text = TranslateString("Collect anonymous information about tool usage : tool running time, tool version, OS version.");
     lWillNot.Text = TranslateString("Collect your name, address, or any other personally identifiable information. The information collected is anonymous.");
     llAlreadyCollected.Text = TranslateString("You can check already collected data here");
     lDisable.Text = TranslateString("You can disable data collecting at any time in \"Options\" dialog");
 }
        void OnLanguageChanged()
        {
            Text       = TranslateString("Filter of languages");
            lInfo.Text = TranslateString("Choose languages you want to translate from and to. Disabled languages will be removed from \"Languages\" tab of default profile");

            gbFrom.Text = TranslateString("Source languages");
            gbTo.Text   = TranslateString("Target languages");


            bCancel.Text = LangPack.TranslateString("Cancel");
            bOk.Text     = TranslateString("OK");

            LoadLanguages();
        }
Esempio n. 22
0
        static void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            if (state == UpdateState.Cancel)
            {
                Cancelled();
                return;
            }

            if (e.Cancelled || e.Error != null)
            {
                if (e.Error != null)
                {
                    SetErrorState(string.Format(CultureInfo.InvariantCulture, LangPack.TranslateString("Error on downloading {0}"), urlToDownload) + "\r\n" + e.Error.Message);
                }
                else
                {
                    SetErrorState(LangPack.TranslateString("Canceled"));
                }
                return;
            }

            string pathToAppData = FreeCL.Forms.Application.DataFolder + Path.DirectorySeparatorChar + "Update";

            if (!Directory.Exists(pathToAppData))
            {
                Directory.CreateDirectory(pathToAppData);
            }
            updateFileName = pathToAppData + Path.DirectorySeparatorChar + fileName;
            if (File.Exists(updateFileName))
            {
                try
                {
                    File.Delete(updateFileName);
                }
                catch
                {
                    SetErrorState(string.Format(CultureInfo.InvariantCulture, LangPack.TranslateString("File {0} already exists"), updateFileName));
                    return;
                }
            }

            FileStream fs = new FileStream(updateFileName, FileMode.Create, FileAccess.Write, FileShare.None);

            fs.Write(e.Result, 0, e.Result.Length);
            fs.Dispose();
            NativeMethods.MarkFileToDeleteOnReboot(updateFileName);
            state = UpdateState.UpdateDownloaded;
        }
Esempio n. 23
0
            void GenerateData()
            {
                name = "";
                if (!string.IsNullOrEmpty(serviceItemData.ServiceItem.Description))
                {
                    name = LangPack.TranslateString(serviceItemData.ServiceItem.Description) + " - ";
                }
                name += LangPack.TranslateString(serviceItemData.ServiceItem.Service.FullName);

                type         = ServiceSettingsContainer.GetServiceItemType(serviceItemData.ServiceItem);
                languagePair = LangPack.TranslateLanguage(serviceItemData.LanguagePair.From) +
                               "->" +
                               LangPack.TranslateLanguage(serviceItemData.LanguagePair.To);

                subject = LangPack.TranslateString(serviceItemData.Subject);
            }
        public static string GetServiceItemType(ServiceItem serviceItem)
        {
            string result;

            if (serviceItem is Translator)
            {
                result = LangPack.TranslateString("Translator");
            }
            else if (serviceItem is AntonymsDictionary)
            {
                result = LangPack.TranslateString("Dictionary of antonyms");
            }
            else if (serviceItem is SynonymsDictionary)
            {
                result = LangPack.TranslateString("Dictionary of synonyms");
            }
            else if (serviceItem is PhraseologicalDictionary)
            {
                result = LangPack.TranslateString("Phraseological dictionary");
            }
            else if (serviceItem is Encyclopedia)
            {
                result = LangPack.TranslateString("Encyclopedia");
            }
            else if (serviceItem is MonolingualSearchEngine || serviceItem is BilingualSearchEngine)
            {
                result = LangPack.TranslateString("Search Engine");
            }
            else if (serviceItem is MonolingualDictionary)
            {
                result = LangPack.TranslateString("Monolingual dictionary");
            }
            else if (serviceItem is BilingualPhrasesDictionary)
            {
                result = LangPack.TranslateString("Bilingual phrases dictionary");
            }
            else if (serviceItem is BilingualSentensesDictionary)
            {
                result = LangPack.TranslateString("Bilingual sentenses dictionary");
            }
            else
            {
                result = LangPack.TranslateString("Bilingual dictionary");
            }
            return(result);
        }
Esempio n. 25
0
        string GetNewProfileName()
        {
            string nameBase = "";

            if (profile.TranslationDirection.From != Language.Any)
            {
                nameBase += StringParser.SafeResizeString(LangPack.TranslateLanguage(profile.TranslationDirection.From), 3);
            }
            else
            {
                nameBase += LangPack.TranslateLanguage(profile.TranslationDirection.From);
            }

            nameBase += "->";

            if (profile.TranslationDirection.To != Language.Any)
            {
                nameBase += StringParser.SafeResizeString(LangPack.TranslateLanguage(profile.TranslationDirection.To), 3);
            }
            else
            {
                nameBase += LangPack.TranslateLanguage(profile.TranslationDirection.To);
            }

            if (profile.Subject != SubjectConstants.Any && profile.Subject != SubjectConstants.Common)
            {
                nameBase += "->" + StringParser.SafeResizeString(LangPack.TranslateString(profile.Subject), 3);
            }

            if (!IsProfileNameExists(nameBase, profile.Name))
            {
                return(nameBase);
            }

            string result;

            for (int i = 1; i < 1000; i++)
            {
                result = nameBase + " " + i.ToString();
                if (!IsProfileNameExists(result, profile.Name))
                {
                    return(result);
                }
            }
            return("");
        }
Esempio n. 26
0
        void LoadLanguages()
        {
            LockUpdate(true);
            lbFrom.BeginUpdate();
            lbFrom.Items.Clear();
            lbTo.Items.Clear();

            LanguageCollection fromLangs = new LanguageCollection();
            int index;

            foreach (LanguagePair lp in languages)
            {
                index = fromLangs.BinarySearch(lp.From);
                if (index < 0)
                {
                    fromLangs.Insert(~index, lp.From);
                }
            }


            string val = "";

            if (fromLangs.Count > 1)
            {
                val = "+" + LangPack.TranslateLanguage(Language.Any);
                lbFrom.Items.Add(new LanguageDataContainer(Language.Any, val));
            }

            foreach (Language l in fromLangs)
            {
                val = LangPack.TranslateLanguage(l);
                if (l == Language.Autodetect)
                {
                    val = "÷" + val;
                }
                lbFrom.Items.Add(new LanguageDataContainer(l, val));
            }

            lbFrom.EndUpdate();

            if (lbFrom.Items.Count > 0 && !profileChanging)
            {
                lbFrom.SelectedIndex = 0;
            }
            LockUpdate(false);
        }
        static void GenerateListByUrlHtml(WebBrowser wBrowser)
        {
            string nodeName = "list_by_url";

            string InnerHtml = GenerateTopNode(nodeName, LangPack.TranslateString("Grouped by Service's Url") + " - " + Manager.Services.Count.ToString(), 0, true);

            HtmlHelper.AddTranslationCell(wBrowser, null, true, InnerHtml, null);

            HtmlHelper.CreateTable(wBrowser, nodeName, nodeName + "_table");

            SortedDictionary <string, List <ServiceItem> > list = new SortedDictionary <string, List <ServiceItem> >();

            foreach (Service service in Manager.Services)
            {
                List <ServiceItem> inner_list = new List <ServiceItem>();
                list.Add(service.Url.AbsoluteUri, inner_list);
                foreach (Translator translator in service.Translators)
                {
                    inner_list.Add(translator);
                }
                foreach (BilingualDictionary dictionary in service.BilingualDictionaries)
                {
                    inner_list.Add(dictionary);
                }
                foreach (MonolingualDictionary dictionary in service.MonolingualDictionaries)
                {
                    inner_list.Add(dictionary);
                }
            }

            bool is_first = true;

            foreach (KeyValuePair <string, List <ServiceItem> > kvp in list)
            {
                foreach (ServiceItem si in kvp.Value)
                {
                    GenerateServiceItemSell(wBrowser, si, nodeName + "_table_body", is_first, true);
                    if (is_first)
                    {
                        is_first = false;
                    }
                }
            }
        }
Esempio n. 28
0
        public void SetStatistics(long translateTicks)
        {
            if (!TranslateOptions.Instance.ResultWindowOptions.ShowQueryStatistics)
            {
                return;
            }

            string htmlString = string.Format(CultureInfo.InvariantCulture,
                                              LangPack.TranslateString("Full time : {0} s"),
                                              new DateTime(translateTicks).ToString("ss.fffffff", CultureInfo.InvariantCulture));;

            htmlString = "<span style=\"" + HtmlHelper.InfoTextStyle + "\">" + htmlString + "</span>";

            Wait();
            HtmlHelper.AddTranslationCell(wBrowser, isClean, htmlString);

            isClean = false;
            RecalcSizes();
        }
Esempio n. 29
0
 public void LoadHistory()
 {
     //int idx = lbHistory.SelectedIndex;
     lbHistory.BeginUpdate();
     lbHistory.Items.Clear();
     foreach (LanguagePair lp in history)
     {
         LanguageContainerPair lpc = new LanguageContainerPair(
             new LanguageDataContainer(lp.From, LangPack.TranslateLanguage(lp.From)),
             new LanguageDataContainer(lp.To, LangPack.TranslateLanguage(lp.To))
             );
         lbHistory.Items.Add(lpc);
     }
     lbHistory.EndUpdate();
     if (history.Count > 0)
     {
         lbHistory.SelectedIndex = 0;
     }
 }
Esempio n. 30
0
        void LbToSelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbFrom.SelectedIndex == -1 || lbTo.SelectedIndex == -1)
            {
                return;
            }

            Language fromLanguage = ((LanguageDataContainer)lbFrom.SelectedItem).Language;
            Language toLanguage   = ((LanguageDataContainer)lbTo.SelectedItem).Language;

            selection = new LanguagePair(fromLanguage, toLanguage);
            lvServicesEnabled.ListViewItemSorter  = null;
            lvServicesDisabled.ListViewItemSorter = null;


            string caption = LangPack.TranslateLanguage(toLanguage);

            lTo.Text = caption;

            if (SelectionChanged != null)
            {
                SelectionChanged(this, new EventArgs());
            }


            foreach (LanguageContainerPair lp in lbHistory.Items)
            {
                if (lp.From.Language == selection.From && lp.To.Language == selection.To)
                {
                    lbHistory.SelectedItem = lp;
                    break;
                }
            }
            LoadServices(false);
            profile.SelectedLanguagePair = selection;
            if (selection.From != Language.Any && selection.To != Language.Any)
            {
                lvServicesEnabled.ListViewItemSorter  = profile.ServiceSettingComparer;
                lvServicesDisabled.ListViewItemSorter = profile.ServiceSettingComparer;
            }
        }