예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateLanguageCombos()
        {
            ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
            string userLocale           = wsf.GetStrFromWs(wsf.UserWs);

            // Get the set of writing systems.
            Set <NamedWritingSystem> writingSystems =
                LangProject.GetAllNamedWritingSystemsFromLDFs(wsf, userLocale);

            NamedWritingSystem wsSaveVern = (NamedWritingSystem)m_cbVernWrtSys.SelectedItem;
            NamedWritingSystem wsSaveAnal = (NamedWritingSystem)m_cbAnalWrtSys.SelectedItem;

            m_cbAnalWrtSys.Items.Clear();
            m_cbVernWrtSys.Items.Clear();
            m_cbAnalWrtSys.BeginUpdate();
            m_cbVernWrtSys.BeginUpdate();

            foreach (NamedWritingSystem nws in writingSystems)
            {
                m_cbAnalWrtSys.Items.Add(nws);
                m_cbVernWrtSys.Items.Add(nws);
            }

            int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.Name));

            m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            m_cbVernWrtSys.EndUpdate();

            i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.Name));
            m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            m_cbAnalWrtSys.EndUpdate();
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateLanguageCombos()
        {
            var wsSaveVern = (IWritingSystem)m_cbVernWrtSys.SelectedItem;
            var wsSaveAnal = (IWritingSystem)m_cbAnalWrtSys.SelectedItem;

            m_cbAnalWrtSys.BeginUpdate();
            m_cbVernWrtSys.BeginUpdate();
            m_cbAnalWrtSys.Items.Clear();
            m_cbVernWrtSys.Items.Clear();

            // Make sure our manager knows about any writing systems in the template folder.
            // In pathological cases where no projects have been installed these might not be in the global store.
            foreach (var templateLangFile in Directory.GetFiles(FwDirectoryFinder.TemplateDirectory, @"*.ldml"))
            {
                var            id = Path.GetFileNameWithoutExtension(templateLangFile);
                IWritingSystem dummy;
                m_wsManager.GetOrSet(id, out dummy);
            }

            foreach (IWritingSystem ws in m_wsManager.LocalWritingSystems)
            {
                m_cbAnalWrtSys.Items.Add(ws);
                m_cbVernWrtSys.Items.Add(ws);
            }

            if (m_cbVernWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveVern == null ? -1 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
                if (i != -1)
#endif
                m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbVernWrtSys.EndUpdate();

            if (m_cbAnalWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveAnal == null ? -1 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
                if (i != -1)
#endif
                m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbAnalWrtSys.EndUpdate();
        }
예제 #3
0
        private void PopulateVariantCombo(bool fPreserve)
        {
            m_variantName.TextChanged -= m_variantName_TextChanged;             // don't modify the WS while fixing up the combo.
            m_variantName.BeginUpdate();
            IEnumerable <VariantSubtag> orig = VariantSubtags;

            m_variantName.ClearItems();
            m_variantName.Items.AddRange(StandardSubtags.RegisteredVariants.Concat(StandardSubtags.CommonPrivateUseVariants)
                                         .Where(v => v.IsVariantOf(m_ws.LanguageTag)).Cast <object>().ToArray());
            if (orig != null && fPreserve)
            {
                VariantSubtags = orig;
            }
            m_variantName.EndUpdate();
            m_variantName.TextChanged += m_variantName_TextChanged;
        }
예제 #4
0
        private void PopulateVariantCombo(bool fPreserve)
        {
            m_variantName.TextChanged -= m_variantName_TextChanged;             // don't modify the WS while fixing up the combo.
            m_variantName.BeginUpdate();
            VariantSubtag orig = VariantSubtag;

            m_variantName.ClearItems();
            m_variantName.Items.AddRange((from subtag in LangTagUtils.VariantSubtags
                                          where subtag.IsVariantOf(m_ws.Id)
                                          select subtag).ToArray());
            if (orig != null && fPreserve)
            {
                VariantSubtag = orig;
            }
            m_variantName.EndUpdate();
            m_variantName.TextChanged += m_variantName_TextChanged;
        }
예제 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateLanguageCombos()
        {
            var wsSaveVern = (IWritingSystem)m_cbVernWrtSys.SelectedItem;
            var wsSaveAnal = (IWritingSystem)m_cbAnalWrtSys.SelectedItem;

            m_cbAnalWrtSys.BeginUpdate();
            m_cbVernWrtSys.BeginUpdate();
            m_cbAnalWrtSys.Items.Clear();
            m_cbVernWrtSys.Items.Clear();

            foreach (IWritingSystem ws in m_wsManager.LocalWritingSystems)
            {
                m_cbAnalWrtSys.Items.Add(ws);
                m_cbVernWrtSys.Items.Add(ws);
            }

            if (m_cbVernWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveVern == null ? -1 : m_cbVernWrtSys.FindString(wsSaveVern.ToString()));
                if (i != -1)
#endif
                m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbVernWrtSys.EndUpdate();

            if (m_cbAnalWrtSys.Items.Count > 0)
            {
#if !__MonoCS__
                int i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
#else
                // TODO-Linux: mono difference? on mono setting SelectedIndex to 0 on an empty combo throws exception
                int i = (wsSaveAnal == null ? -1 : m_cbAnalWrtSys.FindString(wsSaveAnal.ToString()));
                if (i != -1)
#endif
                m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0);
            }
            m_cbAnalWrtSys.EndUpdate();
        }
        /// <summary>
        /// update the 'encoding converters' combo box with the current values
        /// </summary>
        private void LoadEncodingConverters()
        {
            /// Added to make the list of encoding converters match the list that is given when
            /// the add new converter option is selected. (LT-2955)
            EncConverters encConv = new EncConverters();

            System.Collections.IDictionaryEnumerator de = encConv.GetEnumerator();
            cbEC.BeginUpdate();
            cbEC.Items.Clear();
            cbEC.Sorted = true;
            while (de.MoveNext())
            {
                string name = de.Key as string;
                if (name != null)
                {
                    cbEC.Items.Add(name);
                }
            }
            cbEC.Sorted = false;
            cbEC.Items.Insert(0, m_blankEC);
            cbEC.EndUpdate();
        }