Exemple #1
0
        public async Task <bool> LoadData()
        {
            this.Loading = true;

            ObservableCollection <WaterItem> initItems = new ObservableCollection <WaterItem>(await WaterTable.GetAllAsync());

            //Items = await WaterTable.IncludeTotalCount().ToCollectionAsync(1300); //.ToCollectionAsync(900);

            this.Items             = new ObservableCollection <WaterItem>();
            this.CurrentRegionItem = null;
            foreach (var item in initItems)
            {
                if (item.Ind_name.Split(' ')[0].ToString() != "Неизвестно")
                {
                    this.Items.Add(item);
                }
                ;
            }
            ;
            RaisePropertyChanged("Items");

            /*try
             * {
             *  var geolocator = new Geolocator();
             *  Geoposition position = await geolocator.GetGeopositionAsync();
             *  var str = position.ToString();
             *  Latitued = position.Coordinate.Latitude;
             *  Longitude = position.Coordinate.Longitude;
             *  GetPlaceInfo(Latitued, Longitude);
             * }
             * catch {
             *  GetPlaceInfo(Latitued, Longitude);
             * };*/

            this.RegionItems = new ObservableCollection <RegionWaterItem>();
            var ItemsInGroup = from b in this.Items
                               group b by b.Regname into g
                               select g;

            foreach (var reg in ItemsInGroup)
            {
                try {
                    var i       = reg;
                    var regItem = new RegionWaterItem();
                    regItem.Title = reg.Key.ToString();
                    try
                    {
                        regItem.Code = reg.ToList <WaterItem>().FirstOrDefault().Code.ToString();
                    }
                    catch { };
                    regItem.Items = new ObservableCollection <WaterItem>(reg.ToList <WaterItem>());
                    this.RegionItems.Add(regItem);

                    /*if (regItem.Title.Trim()==this.CurrentDistrict.Trim()) {
                     *  this.CurrentRegionItem = regItem;
                     * };*/
                } catch {};
            }
            ;

            UpdateCoordinatesWatcher();

            if (this.GeoCurrentRegionItem == null)
            {
                this.GeoCurrentRegionItem = this.RegionItems.FirstOrDefault();
            }
            ;

            App.button.Open();
            this.Loading = false;

            return(true);
        }
Exemple #2
0
        public async Task <bool> LoadData()
        {
            this.Loading = true;

            ObservableCollection <WaterItem> initItems = new ObservableCollection <WaterItem>(await WaterTable.GetAllAsync());

            //Items = await WaterTable.IncludeTotalCount().ToCollectionAsync(1300); //.ToCollectionAsync(900);

            this.Items             = new ObservableCollection <WaterItem>();
            this.CurrentRegionItem = null;
            foreach (var item in initItems)
            {
                if (item.Ind_name.Split(' ')[0].ToString() != "Неизвестно")
                {
                    this.Items.Add(item);
                }
                ;
            }
            ;
            RaisePropertyChanged("Items");

            //await GetCurrentPosition();

            this.RegionItems = new ObservableCollection <RegionWaterItem>();
            var ItemsInGroup = from b in this.Items
                               group b by b.Regname into g
                               select g;

            foreach (var reg in ItemsInGroup)
            {
                try {
                    var i       = reg;
                    var regItem = new RegionWaterItem();
                    regItem.Title = reg.Key.ToString();
                    try
                    {
                        regItem.Code = reg.ToList <WaterItem>().FirstOrDefault().Code.ToString();
                    }
                    catch { };
                    regItem.Items = new ObservableCollection <WaterItem>(reg.ToList <WaterItem>());
                    this.RegionItems.Add(regItem);

                    /*if (regItem.Title.Trim()==this.CurrentDistrict.Trim()) {
                     *  this.CurrentRegionItem = regItem;
                     * };*/
                } catch {};
            }
            ;

            await GetCurrentPosition();

            if (this.CurrentRegionItem == null)
            {
                this.CurrentRegionItem = this.RegionItems.FirstOrDefault();
            }
            ;

            this.Loading = false;

            return(true);
        }