コード例 #1
0
        async Task ExecuteLoadBirdsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                KnownBirds.Clear();
                var _birds = await BirdService.GetKnownBirdsAsync();

                foreach (var tmpBird in _birds)
                {
                    KnownBird tmpKB = new KnownBird();

                    tmpKB.BirdID         = tmpBird.BirdID;
                    tmpKB.Name           = tmpBird.Name;
                    tmpKB.examplePicture = tmpBird.examplePicture;
                    tmpKB.displayName    = tmpBird.displayName;

                    //Change this to URL when setting this from the REST API and not the local data.
                    //tmpKB.BirdImage = ImageSource.FromResource("BirdWatcherMobileApp.SampleData.images." + tmpBird.examplePicture);

                    tmpKB.BirdImage = new UriImageSource {
                        CachingEnabled = false, Uri = new Uri("http://" + Settings.ServerAddress + "/images/bird_examples/" + tmpBird.examplePicture)
                    };

                    KnownBirds.Add(tmpKB);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }