Exemplo n.º 1
0
 /// <summary>
 /// download coordiantes from APIs and return them
 /// </summary>
 /// <param name="url">input url in string</param>
 /// <param name="inputSearch">searched text</param>
 /// <returns></returns>
 string DownloadCoords(string url, string inputSearch)
 {
     try
     {
         WebDownload wc = new WebDownload();
         string s = wc.DownloadString(String.Format(url, inputSearch));
         return s;
     }
     catch (WebException)
     {
         return "";
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// check if BingMaps API codes are good to go
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtboxBmKey_LostFocus(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TxtboxBmKey.Text) || TxtboxBmKey.Text == "Fill this key please!")
     {
         TxtboxBmKey.Text = "Fill this key please!";
         ImgBm.Source = new BitmapImage(new Uri("/images/question.png", UriKind.Relative));
         CbxBm.IsEnabled = false;
     }
     else
     {
         try
         {
             string url = "http://dev.virtualearth.net/REST/v1/Locations?q=Ostrava&o=xml&maxRes=1&key=" + TxtboxBmKey.Text;
             WebDownload wc = new WebDownload();
             string s = wc.DownloadString(url);
             if (RegexBetween(s, "<StatusDescription>(.*)</StatusDescription>") == "OK" &&
                 RegexBetween(s, "<EstimatedTotal>(.*)</EstimatedTotal>") == "1")
             {
                 ImgBm.Source = new BitmapImage(new Uri("/images/accept.png", UriKind.Relative));
                 CbxBm.IsEnabled = true;
             }
             else
             {
                 ImgBm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
                 CbxBm.IsEnabled = false;
             }
         }
         catch (WebException)
         {
             ImgBm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
             CbxBm.IsEnabled = false;
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// check if openMapQuest API codes are good to go
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtboxMqKey_LostFocus(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TxtboxMqKey.Text) || TxtboxMqKey.Text == "Fill this key please!")
     {
         TxtboxMqKey.Text = "Fill this key please!";
         ImgMq.Source = new BitmapImage(new Uri("/images/question.png", UriKind.Relative));
         CbxMq.IsEnabled = false;
     }
     else
     {
         try
         {
             string url = "http://open.mapquestapi.com/geocoding/v1/address?key=" + TxtboxMqKey.Text +
                          "&outFormat=xml&maxResults=1&thumbMaps=false&location=Ostrava";
             WebDownload wc = new WebDownload();
             string s = wc.DownloadString(url);
             if (RegexBetween(s, "<statusCode>(.*)</statusCode>") == "0")
             {
                 ImgMq.Source = new BitmapImage(new Uri("/images/accept.png", UriKind.Relative));
                 CbxMq.IsEnabled = true;
             }
             else
             {
                 ImgMq.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
                 CbxMq.IsEnabled = false;
             }
         }
         catch (WebException)
         {
             ImgMq.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
             CbxMq.IsEnabled = false;
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// check if GoogleMaps API codes are good to go
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtboxGmKey_LostFocus(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TxtboxGmKey.Text) || TxtboxGmKey.Text == "Fill this key please!")
     {
         TxtboxGmKey.Text = "Fill this key please!";
         ImgGm.Source = new BitmapImage(new Uri("/images/question.png", UriKind.Relative));
         CbxGm.IsEnabled = false;
     }
     else
     {
         try
         {
             string url = "https://maps.googleapis.com/maps/api/geocode/xml?address=Ostrava&key=" + TxtboxGmKey.Text;
             WebDownload wc = new WebDownload();
             string s = wc.DownloadString(url);
             if (RegexBetween(s, "<status>(.*)</status>") == "OK")
             {
                 ImgGm.Source = new BitmapImage(new Uri("/images/accept.png", UriKind.Relative));
                 CbxGm.IsEnabled = true;
             }
             else
             {
                 ImgGm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
                 CbxGm.IsEnabled = false;
             }
         }
         catch (WebException)
         {
             ImgGm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
             CbxGm.IsEnabled = false;
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// check if HereMaps API codes are good to go
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtboxHmAppId_LostFocus(object sender, RoutedEventArgs e)
 {
     if ((string.IsNullOrWhiteSpace(TxtboxHmAppId.Text) || TxtboxHmAppId.Text == "Fill this key please!")
         &&
         (string.IsNullOrWhiteSpace(TxtboxHmAppCode.Text) || TxtboxHmAppCode.Text == "Fill this key please!"))
     {
         TxtboxHmAppId.Text = "Fill this key please!";
         TxtboxHmAppCode.Text = "Fill this key please!";
         ImgHm.Source = new BitmapImage(new Uri("/images/question.png", UriKind.Relative));
         CbxHm.IsEnabled = false;
     }
     else if ((string.IsNullOrWhiteSpace(TxtboxHmAppId.Text) || TxtboxHmAppId.Text == "Fill this key please!")
             &&
             (string.IsNullOrWhiteSpace(TxtboxHmAppCode.Text) == false || TxtboxHmAppCode.Text != "Fill this key please!"))
     {
         TxtboxHmAppId.Text = "Fill this key please!";
         ImgHm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
         CbxHm.IsEnabled = false;
     }
     else if ((string.IsNullOrWhiteSpace(TxtboxHmAppId.Text) == false || TxtboxHmAppId.Text != "Fill this key please!")
             &&
             (string.IsNullOrWhiteSpace(TxtboxHmAppCode.Text) || TxtboxHmAppCode.Text == "Fill this key please!"))
     {
         TxtboxHmAppCode.Text = "Fill this key please!";
         ImgHm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
         CbxHm.IsEnabled = false;
     }
     else
     {
         try
         {
             string url = "http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=" + TxtboxHmAppId.Text + "&app_code=" + TxtboxHmAppCode.Text + "&gen=9&searchtext=Ostrava";
             WebDownload wc = new WebDownload();
             string s = wc.DownloadString(url);
             if (RegexBetween(s, "<ViewId>(.*)</ViewId>") == "0")
             {
                 ImgHm.Source = new BitmapImage(new Uri("/images/accept.png", UriKind.Relative));
                 CbxHm.IsEnabled = true;
             }
             else
             {
                 ImgHm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
                 CbxHm.IsEnabled = false;
             }
         }
         catch (WebException)
         {
             ImgHm.Source = new BitmapImage(new Uri("/images/cancel.png", UriKind.Relative));
             CbxHm.IsEnabled = false;
         }
     }
 }