Esempio n. 1
0
        public override SubjectCollection GetSupportedSubjects()
        {
            if (!disabledLanguagesAlreadySet)
            {
                return(Manager.Subjects);
            }
            else
            {
                PrepareProcessing();
                SubjectCollection subjects = new SubjectCollection();
                int index;
                foreach (ServiceItem item in Manager.ServiceItems)
                {
                    foreach (LanguagePair lp in item.SupportedTranslations)
                    {
                        if (disabledSourceLanguages.BinarySearch(lp.From) >= 0)
                        {
                            continue;
                        }

                        if (disabledTargetLanguages.BinarySearch(lp.To) >= 0)
                        {
                            continue;
                        }

                        foreach (string subject in item.SupportedSubjects)
                        {
                            index = subjects.BinarySearch(subject);
                            if (index < 0)
                            {
                                subjects.Insert(~index, subject);
                            }
                        }

                        break;
                    }
                }
                return(subjects);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        void LbFromSelectedIndexChanged(object sender, EventArgs e)
        {
            LockUpdate(true);
            if (lbFrom.SelectedIndex == -1)
            {
                return;
            }

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

            if (lbTo.SelectedItem != null)
            {
                toLanguage = ((LanguageDataContainer)lbTo.SelectedItem);
            }

            lbTo.BeginUpdate();

            lbTo.Items.Clear();

            LanguageCollection toLangs = new LanguageCollection();
            int index;

            foreach (LanguagePair lp in languages)
            {
                if ((lp.From == fromLanguage || fromLanguage == Language.Any))
                {
                    index = toLangs.BinarySearch(lp.To);
                    if (index < 0)
                    {
                        toLangs.Insert(~index, lp.To);
                    }
                }
            }

            string val = "";

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

            foreach (Language l in toLangs)
            {
                val = LangPack.TranslateLanguage(l);
                lbTo.Items.Add(new LanguageDataContainer(l, val));
            }
            lbTo.EndUpdate();

            string caption = LangPack.TranslateLanguage(fromLanguage);

            lFrom.Text = caption;

            int idx = -1;

            if (toLanguage != null)
            {
                idx = lbTo.Items.IndexOf(toLanguage);
            }

            if (idx == -1)
            {
                idx = 0;
            }
            lbTo.SelectedIndex = idx;
            LockUpdate(false);
        }