Example #1
0
        public void SetPMLanguageList(XMLRLData data)
        {
            if (data.IsNull())
            {
                return;
            }
            this.m_TSCBPref.Items.Clear();
            foreach (KeyValuePair <string, string> kv in data.GetList())
            {
                // Initialize object
                ToolStripLabel tsl = new ToolStripLabel(kv.Value);

                // ToolStripLabel
                tsl.Name = kv.Key;

                // ToolStripComboBox
                this.m_TSCBPref.Items.Add(tsl);
            }

            // Enabled
            string lang = this.m_RegConfig.GetPrefLang();

            if (lang == "")
            {
                this.m_TSMINoDef.Checked      = true;
                this.m_TSCBPref.SelectedIndex = 0;
                return;
            }
            this.p_SetSelectedItem(lang, this.m_TSCBPref.ComboBox);
            this.m_TSCBPref.Enabled = true;
        }
Example #2
0
        private async void M_UTimer_Tick(object sender, EventArgs e)
        {
            this.m_UTimer.Stop();
            this.SetStatusText(this.m_CRManager.GetString("GetLangs"));
            string r = "";

            try
            {
                r = await this.m_APIManager.GetLanguages();
            }
            catch (Exception)
            {
                Refresh dlg = new YAT.Refresh();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    this.m_UTimer.Start();
                    return;
                }
                else
                {
                    this.Close();
                }
            }
            XMLRLData data = new XMLRLData(r);

            this.SetPMLanguageList(data);
            this.SetLanguageList(data);
        }
Example #3
0
        // Public methods
        public void SetLanguageList(XMLRLData data)
        {
            if (data.IsNull())
            {
                switch (data.GetCode())
                {
                case (int)APIError.GETLANGS_BAD_KEY:
                    this.SetStatusText(Errors.EReason);
                    break;

                case (int)APIError.GETLANGS_BLOCK_KEY:
                    this.SetStatusText(Errors.FReason);
                    break;

                default:
                    this.SetStatusText(Errors.GReason);
                    break;
                }
                return;
            }
            this.m_FComboBox.Items.Clear();
            this.m_TComboBox.Items.Clear();
            foreach (KeyValuePair <string, string> kv in data.GetList())
            {
                // Initialize object
                ToolStripLabel tsl = new ToolStripLabel(kv.Value);

                // ToolStripLabel
                tsl.Name = kv.Key;

                // ComboBox
                this.m_FComboBox.Items.Add(tsl);
                this.m_TComboBox.Items.Add(tsl);
            }
            this.p_Enabled();

            // Hold languages
            bool on = this.m_RegConfig.GetHoldLang();

            if (!on)
            {
                string lang = "";

                // Preffered language translation or <System> CurrentUICulture
                lang = this.m_RegConfig.GetPrefLang();
                if (lang == "")
                {
                    lang = Thread.CurrentThread.CurrentUICulture.Name;
                    lang = Util.GetNormalizeLang(lang);
                }

                // ComboBox <From>
                this.p_SetSelectedItem(lang, this.m_FComboBox);

                // Save last language
                lang = this.m_RegConfig.GetLastLang();
                if (lang == "")
                {
                    this.m_TComboBox.SelectedIndex = 0;
                    return;
                }

                // ComboBox <To>
                this.p_SetSelectedItem(lang, this.m_TComboBox);
            }
            else
            {
                this.p_HoldLang();
            }
        }