Exemplo n.º 1
0
        private void LoadProvinces()
        {
            Provinces.Clear();

            IsLoadingCity = true;
            var action = new Action(() =>
            {
                var tempBanks = BankData.GetBanks();

                if (tempBanks != null)
                {
                    foreach (var item in tempBanks)
                    {
                        DispatcherHelper.UIDispatcher.Invoke(new Action <BankInfo>(Banks.Add), item);
                    }
                }
                //if (!isUpdate)
                SelectBank();

                var temp = CityData.GetAllState();
                if (temp != null)
                {
                    foreach (var item in temp)
                    {
                        DispatcherHelper.UIDispatcher.Invoke(new Action <CityModel>(Provinces.Add), item);
                    }
                }
                SelectProvince();
            });

            Task.Factory.StartNew(action).ContinueWith((task) =>
            {
                DispatcherHelper.UIDispatcher.Invoke(new Action(() =>
                {
                    IsLoadingCity = false;
                }));
            });
        }
Exemplo n.º 2
0
        private void ReadProvinceDefinition()
        {
            Provinces.Clear();

            string pathOfProvinceDefinition = $@"{Application.StartupPath}\{"definition.csv"}";

            if (!File.Exists(pathOfProvinceDefinition))
            {
                return;
            }
            string[] definitions = File.ReadAllLines(pathOfProvinceDefinition, m_encoding1252);

            foreach (string definition in definitions)
            {
                string[] listSplittedDefinition = definition.Split(';');

                if (listSplittedDefinition.Length < 5)
                {
                    continue;
                }

                int.TryParse(listSplittedDefinition[0], out int idProvince);
                int.TryParse(listSplittedDefinition[1], out int r);
                int.TryParse(listSplittedDefinition[2], out int g);
                int.TryParse(listSplittedDefinition[3], out int b);

                string nameOf = listSplittedDefinition[4];

                var provinceDefinitionItem = Provinces.Find(searchItem => ((searchItem.R == r) && (searchItem.G == g) && (searchItem.B == b)));

                if (provinceDefinitionItem == null)
                {
                    Provinces.Add(new ProvinceDefinitionItem(idProvince, r, g, b, nameOf, string.Empty));
                }
            }
        }