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"); dgvServices.Columns.Remove("Auth"); //resize columns dgvServices.Columns[0].Width = dgvServices.Width; dgvServices.ClearSelection(); _init = false; if (tilemaps.Count > 0) { btnOk.Enabled = false; } }
private bool CheckUrl(string url) { var result = false; if (!UrlIsValid(url)) { return(false); } try { TmsTileMapServiceParser.GetTileMaps(url); result = true; } catch (WebException) { errorProvider1.SetError(tbTmsUrl, "Could not download document. Please specify valid url"); } catch (XmlException) { errorProvider1.SetError(tbTmsUrl, "Could not download XML document. Please specify valid url"); } return(result); }