Пример #1
0
        private static string GetCountryNameFromCode(string code)
        {
            var countryName = string.Empty;

            var country = StoreHelper.GetAllCountries().FirstOrDefault(x => x.Code == code);

            if (country != null)
            {
                countryName = country.Name;
            }

            if (country == null)
            {
                var cultureList = new Dictionary <string, string>();

                var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

                foreach (var region in cultures.Select(culture => new RegionInfo(culture.LCID)).Where(region => !(cultureList.ContainsKey(region.TwoLetterISORegionName))))
                {
                    cultureList.Add(region.TwoLetterISORegionName, region.EnglishName);
                }

                countryName = cultureList.FirstOrDefault(x => x.Key == code).Value;
            }

            return(countryName);
        }
Пример #2
0
        public static string GetFullCountryNameFromCountry(string country, string storeAlias)
        {
            var Country = StoreHelper.GetAllCountries(storeAlias).FirstOrDefault(x => country != null && x.Code == country);

            if (Country != null)
            {
                return(country != null ? Country.Name : string.Empty);
            }

            return(string.Empty);
        }
Пример #3
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _dlCountries = new DropDownList();

            foreach (var countryListItem in StoreHelper.GetAllCountries().Select(country => new ListItem(country.Name, country.Code)))
            {
                _dlCountries.Items.Add(countryListItem);
            }

            _dlCountries.SelectedValue = _data.Value.ToString();

            if (ContentTemplateContainer != null)
            {
                ContentTemplateContainer.Controls.Add(_dlCountries);
            }
        }
Пример #4
0
 public IEnumerable <CountryData> GetCountrySelector()
 {
     return(StoreHelper.GetAllCountries().Select(country => new CountryData(country.Name, country.Code)));
 }
Пример #5
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _Table = new Table();

            _tableRow = new TableRow();

            _tCellFirst = new TableCell {
                VerticalAlign = VerticalAlign.Top, Width = 260
            };
            _tableRow.Cells.Add(_tCellFirst);
            _tCellSecond = new TableCell {
                VerticalAlign = VerticalAlign.Middle
            };
            _tableRow.Cells.Add(_tCellSecond);
            _tCellThird = new TableCell {
                VerticalAlign = VerticalAlign.Top, Width = 260
            };
            _tableRow.Cells.Add(_tCellThird);

            _Table.Rows.Add(_tableRow);


            var items         = StoreHelper.GetAllCountries().Select(country => new ListItem(country.Name, country.Code)).OrderBy(x => x.Text).ToList();
            var selectedItems = GetSelectedCountries().Select(country => new ListItem(country.Name, country.Code)).OrderBy(x => x.Text).ToList();

            foreach (var selectedItem in selectedItems)
            {
                if (items.Contains(selectedItem))
                {
                    items.Remove(selectedItem);
                }
            }

            _lbAllItems = new ListBox {
                SelectionMode = ListSelectionMode.Multiple, Width = 250, Rows = 10
            };
            foreach (var item in items)
            {
                _lbAllItems.Items.Add(new ListItem(item.Text, item.Value));
            }
            _lbAllItems.DataBind();

            var allItemsText = library.GetDictionaryItem("AllItems");

            if (string.IsNullOrEmpty(allItemsText))
            {
                allItemsText = "All items";
            }

            _lblAllItems = new Label {
                Text = allItemsText, AssociatedControlID = _lbAllItems.ID
            };


            var addText = library.GetDictionaryItem("Add");

            if (string.IsNullOrEmpty(addText))
            {
                addText = "Add";
            }

            var removeText = library.GetDictionaryItem("Remove");

            if (string.IsNullOrEmpty(removeText))
            {
                removeText = "Remove";
            }

            _tCellFirst.Controls.Add(_lblAllItems);
            _tCellFirst.Controls.Add(_lbAllItems);

            _btnMoveLeft = new Button {
                Text = removeText
            };
            _btnMoveLeft.Click += BtnMoveLeftClick;

            _btnMoveRight = new Button {
                Text = addText
            };
            _btnMoveRight.Click += BtnMoveRightClick;

            _tCellSecond.Controls.Add(_btnMoveLeft);
            _tCellSecond.Controls.Add(_btnMoveRight);


            _lbSelectedItems = new ListBox {
                SelectionMode = ListSelectionMode.Multiple, Width = 250, Rows = 10
            };
            foreach (var selectedItem in selectedItems)
            {
                _lbSelectedItems.Items.Add(new ListItem(selectedItem.Text, selectedItem.Value));
            }
            _lbSelectedItems.DataBind();

            var selectedItemsText = library.GetDictionaryItem("SelectedItems");

            if (string.IsNullOrEmpty(selectedItemsText))
            {
                selectedItemsText = "Selected items";
            }

            _lblSelectedItems = new Label {
                Text = selectedItemsText, AssociatedControlID = _lbSelectedItems.ID
            };

            _tCellThird.Controls.Add(_lblSelectedItems);
            _tCellThird.Controls.Add(_lbSelectedItems);


            if (ContentTemplateContainer != null)
            {
                ContentTemplateContainer.Controls.Add(_Table);
            }

            //if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblAllItems);
            //if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lbAllItems);

            //if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_btnMoveLeft);
            //if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_btnMoveRight);

            //if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblSelectedItems);
            //if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lbSelectedItems);
        }
Пример #6
0
        /// <summary>
        /// Returns the full country name from the given countrycode
        /// </summary>
        /// <param name="countryCode">The country code.</param>
        /// <returns></returns>
        public static string CountryNameFromCode(string countryCode)
        {
            var country = StoreHelper.GetAllCountries().FirstOrDefault(x => x.Code == countryCode);

            return(country != null ? country.Name : string.Empty);
        }
Пример #7
0
 /// <summary>
 /// Get all the countires from country.xml or country_storealias.xml
 /// If not found a fallback list will be used
 /// </summary>
 /// <returns></returns>
 public static List <Country> GetAllCountries()
 {
     return(StoreHelper.GetAllCountries(StoreHelper.CurrentStoreAlias));
 }