Пример #1
0
        /// <summary>
        /// Loads the given ComboBox with the available languages.
        /// </summary>
        /// <param name="combo">ComboBox to load</param>
        /// <history>
        /// [Curtis_Beard]		05/18/2007	Created
        /// </history>
        public static void LoadComboBox(ComboBox combo)
        {
            combo.Items.Clear();
            combo.DisplayMember = "DisplayName";
            combo.ValueMember   = "Culture";

            if (Directory.Exists(LanguageLocation))
            {
                string[] files = Directory.GetFiles(LanguageLocation, "*.xml");

                if (files.Length > 0)
                {
                    foreach (string file in files)
                    {
                        // retrieve language information from file
                        string displayName = string.Empty;
                        string culture     = string.Empty;
                        GetLanguageInformation(file, ref displayName, ref culture);

                        // valid language file
                        if (!displayName.Equals(string.Empty) && !culture.Equals(string.Empty))
                        {
                            LanguageItem item = new LanguageItem(displayName, culture);
                            combo.Items.Add(item);
                        }
                    }
                }
            }

            // only load embedded language if a failure occurred
            if (combo.Items.Count == 0)
            {
                LanguageItem item = new LanguageItem("English (U.S.)", "en-us");
                combo.Items.Add(item);
            }
        }
Пример #2
0
        /// <summary>
        /// Loads the given ComboBox with the available languages.
        /// </summary>
        /// <param name="combo">ComboBox to load</param>
        /// <history>
        /// [Curtis_Beard]		05/18/2007	Created
        /// </history>
        public static void LoadComboBox(ComboBox combo)
        {
            combo.Items.Clear();
             combo.DisplayMember = "DisplayName";
             combo.ValueMember = "Culture";

             if (Directory.Exists(LanguageLocation))
             {
            string[] files = Directory.GetFiles(LanguageLocation, "*.xml");

            if (files.Length > 0)
            {
               foreach (string file in files)
               {
                  // retrieve language information from file
                  string displayName = string.Empty;
                  string culture = string.Empty;
                  GetLanguageInformation(file, ref displayName, ref culture);

                  // valid language file
                  if (!displayName.Equals(string.Empty) && !culture.Equals(string.Empty))
                  {
                     LanguageItem item = new LanguageItem(displayName, culture);
                     combo.Items.Add(item);
                  }
               }
            }
             }

             // only load embedded language if a failure occurred
             if (combo.Items.Count == 0)
             {
            LanguageItem item = new LanguageItem("English (U.S.)", "en-us");
            combo.Items.Add(item);
             }
        }