public LandingSiteForm(TargetArea targetArea, MainForm parent, Landingsite landingSite, bool isNew = false) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // _targetArea = targetArea; _parentForm = parent; _isNew = isNew; _landingSite = landingSite; Text = "Landing site"; if (_isNew) { Text = "New landing site"; _landingSite.IsNew(); } SetupProvinceComboBox(); }
public void ParseLandingSites() { if (TargetArea != null && File.Exists(KMLFile)) { FishingGrid.TargetAreaGuid = TargetArea.TargetAreaGuid; var grid25 = FishingGrid.Grid25; var doc = new XmlDocument(); var inLandingSiteFolder = false; var landingSiteName = string.Empty; double xCoordinate = 0, yCoordinate = 0; doc.Load(KMLFile); foreach (XmlNode nd in doc.DocumentElement.SelectNodes("//*")) { if (nd.Name == "Folder") { foreach (XmlNode cnd in nd.ChildNodes) { switch (cnd.Name) { case "name": inLandingSiteFolder = false; if (string.Equals(cnd.InnerXml, "Landing site", System.StringComparison.CurrentCultureIgnoreCase) || string.Equals(cnd.InnerXml, "Landing sites", System.StringComparison.CurrentCultureIgnoreCase)) { inLandingSiteFolder = true; } break; case "Placemark": if (inLandingSiteFolder) { foreach (XmlNode pl in cnd.ChildNodes) { if (pl.Name == "name") { landingSiteName = pl.InnerXml; } else if (pl.Name == "Point") { foreach (XmlNode pt in pl.ChildNodes) { if (pt.Name == "coordinates") { var arr = pt.InnerXml.Split(','); xCoordinate = double.Parse(arr[0]); yCoordinate = double.Parse(arr[1]); if (OnLandingSiteRetrieved != null) { Landingsite ls = new Landingsite { LandingSiteName = landingSiteName, }; ls.xyKMLCoordinate(xCoordinate, yCoordinate, IsInside(grid25, xCoordinate, yCoordinate)); OnLandingSiteRetrieved(this, ls); } } } } } } break; } } } } } }