예제 #1
0
        private static string GetWeatherTileTemplateAsImageFile(City SelectedCity)
        {
            TileControl TileTemplate = new TileControl();
            TileTemplate.DataContext = SelectedCity;

            TileTemplate.Measure(new Size(173, 173));
            TileTemplate.Arrange(new Rect(0, 0, 173, 173));
            var bmp = new WriteableBitmap(173, 173);
            bmp.Render(TileTemplate, null);
            bmp.Invalidate();

            var isf = IsolatedStorageFile.GetUserStoreForApplication();
            var filename = "/Shared/ShellContent/tile.jpg";

            if (!isf.DirectoryExists("/Shared/ShellContent"))
            {
                isf.CreateDirectory("/Shared/ShellContent");
            }

            using (var stream = isf.OpenFile(filename, FileMode.OpenOrCreate))
            {
                bmp.SaveJpeg(stream, 173, 173, 0, 100);
            }

            return filename;
        }
예제 #2
0
        public static async void GetCurrentDeviceGeoLocation()
        {
            Geocoordinate GeoCorResult = await GetCurrentGeoPosition();
            CurrentCity = new City();
            CurrentCity.Latitude = GeoCorResult.Latitude;
            CurrentCity.Longitude = GeoCorResult.Longitude;

            ReverseGeocodeQuery RGeoQ = new ReverseGeocodeQuery();
            RGeoQ.GeoCoordinate = new GeoCoordinate(GeoCorResult.Latitude, GeoCorResult.Longitude);
            RGeoQ.QueryCompleted += reverseGeocode_QueryCompleted;
            RGeoQ.QueryAsync();
        }
예제 #3
0
 public static void PinCityWeatherTile(City SelectedCity)
 {
     if (SelectedCity.IsCurrentCity)
     {
         MessageBox.Show(SelectedCity.CityName + " is Aleardy Pinned");
         return;
     }
     FlipTileData PrimaryTileData = new FlipTileData();
     PrimaryTileData.Count = 0;
     PrimaryTileData.Title = "WeatherApp";
     PrimaryTileData.BackgroundImage = new Uri("isostore:" + GetWeatherTileTemplateAsImageFile(SelectedCity), UriKind.Absolute);
     if (!IsCityTilePinned(SelectedCity.CityName))
     {
         ShellTile.Create(new Uri("/MainPage.xaml?City=" + SelectedCity.CityName, UriKind.Relative), PrimaryTileData, false);
     }
     else
     {
         MessageBox.Show(SelectedCity.CityName + " is Aleardy Pinned");
     }
 }
        public static async Task<Uri> GetCityWeatherPhoto(City WeatherCity)
        {
            Uri PhotoURI = null;
            string Lisences = String.Join(",", FlickrAPILiscenseTypes);
            Lisences.Replace(",", "%2C");

            string TextSearch = WeatherCity.CityName + "%20" + WeatherCity.CityCurrentWeather.WeatherDescription.Replace(" ","%20");
            string SearchURL = string.Format(FLickrAPIURLTemplate, FlickrAPIKey, TextSearch);//, WeatherCity.Latitude, WeatherCity.Longitude);

            string JSONResponse = await WebServiceManager.CallWebService(SearchURL);

            FlickrPhotosSet FLickrData = JsonConvert.DeserializeObject<FlickrPhotosSet>(JSONResponse);
            List<Photo> FoundedPhotos = FLickrData.photos.photo;
            if (FoundedPhotos.Count > 0)
            {
                string PhotoURL = PhotoURL = string.Format(PhotoURLTemplate, FoundedPhotos[0].farm, FoundedPhotos[0].server, FoundedPhotos[0].id, FoundedPhotos[0].secret);
                PhotoURI = new Uri(PhotoURL);
            }
            return PhotoURI;
        }
예제 #5
0
 public bool IsCityExists(City FindCity)
 {
     foreach (City c in CityCollection)
     {
         if (c.CityName == FindCity.CityName)
         {
             return true;
         }
     }
     return false;
 }
예제 #6
0
 public bool RemoveCity(City CityToDelete)
 {
     return this.CityCollection.Remove(CityToDelete);
 }
예제 #7
0
 public bool IsCityExists(City FindCity, bool IsCurrentCityFlag)
 {
     bool IsExist = false;
     foreach (City c in CityCollection)
     {
         if (c.CityName == FindCity.CityName)
         {
             if (c.IsCurrentCity != IsCurrentCityFlag)
             {
                 c.IsCurrentCity = IsCurrentCityFlag;
             }
             IsExist = true;
         }
         else
         {
             c.IsCurrentCity = !IsCurrentCityFlag;
         }
     }
     return IsExist;
 }