protected List<TileMapService> GetList(string url) { var providers = new List<TileMapService>(); var request = (HttpWebRequest)WebRequest.Create(url); request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14"; var proxy = WebRequest.GetSystemWebProxy(); proxy.Credentials = CredentialCache.DefaultCredentials; request.Proxy = proxy; var response = (HttpWebResponse)request.GetResponse(); var stream = response.GetResponseStream(); if (stream != null) { var reader = new StreamReader(stream); while (!reader.EndOfStream) { var line = reader.ReadLine(); var tileMapService = new TileMapService(); if (line != null) { tileMapService.Title = line.Split(',')[0]; tileMapService.Href = line.Split(',')[1]; tileMapService.Version = line.Split(',')[2]; } providers.Add(tileMapService); } } return providers; }
private void lbProvider_SelectedIndexChanged(object sender, EventArgs e) { _init = true; _file = (String)lbProvider.SelectedItem; var res = _servicesDir + Path.DirectorySeparatorChar + _file + ".xml"; var xdoc=XDocument.Load(res); var el=xdoc.Element("Services"); if (el != null) { var el1 = el.Element("TileMapService"); if (el1 != null) SelectedTileMapService = new TileMapService { Title = el1.Attribute("title").Value, Version = el1.Attribute("version").Value, Href = el1.Attribute("href").Value }; } btnRemoveProvider.Enabled = true; var tilemaps=TmsTileMapServiceParser.GetTileMaps(SelectedTileMapService.Href); tilemaps.Sort(TileMap.Compare); dgvServices.DataSource = tilemaps; dgvServices.Columns.Remove("Href"); dgvServices.Columns.Remove("Profile"); dgvServices.Columns.Remove("Srs"); dgvServices.Columns.Remove("Type"); dgvServices.Columns.Remove("OverwriteUrls"); //resize columns dgvServices.Columns[0].Width=120; dgvServices.ClearSelection(); _init = false; if (tilemaps.Count > 0) { btnOk.Enabled = false; } }