private void panelImage_MouseDown(object sender, MouseEventArgs e) { buttonSetAnchorPoint.BackColor = SystemColors.Control; AddAnchorMode = false; if (MapImageRect.Contains(e.Location)) { DlgSelectLocation dlg3 = new DlgSelectLocation(); if (dlg3.ShowDialog() == DialogResult.Cancel) { return; } GCMapAnchor ma = new GCMapAnchor(); ma.Location = dlg3.SelectedLocation.Title; ma.Longitude = dlg3.SelectedLocation.Longitude; ma.Latitude = dlg3.SelectedLocation.Latitude; ma.relX = (double)(e.X - MapImageRect.X) / MapImageRect.Width; ma.relY = (double)(e.Y - MapImageRect.Y) / MapImageRect.Height; SelectedMap.AnchorPoints.Add(ma); SelectedMap.RecalculateDimensions(); panelImage.Invalidate(); buttonSelect.Enabled = SelectedMap.MapUsable; } }
public static void OnStart() { string rootFile = GCGlobal.GetFileName(GCGlobal.MapsFolderPath, "root.xml"); if (File.Exists(rootFile)) { Maps.Clear(); XmlDocument doc = new XmlDocument(); doc.Load(rootFile); foreach (XmlNode mapXmlNode in doc.GetElementsByTagName("maprec")) { if (mapXmlNode is XmlElement mapXmlElement) { GCMap map = new GCMap(); map.Id = new Guid(mapXmlElement.GetAttribute("guid")); map.ImageFilePath = mapXmlElement.GetAttribute("filePath"); map.Title = mapXmlElement.GetAttribute("title"); map.ImageSize = new Size(int.Parse(mapXmlElement.GetAttribute("sizex")), int.Parse(mapXmlElement.GetAttribute("sizey"))); map.LatitudeEnd = double.Parse(mapXmlElement.GetAttribute("latend")); map.LatitudeStart = double.Parse(mapXmlElement.GetAttribute("latstart")); map.LongitudeEnd = double.Parse(mapXmlElement.GetAttribute("longend")); map.LongitudeStart = double.Parse(mapXmlElement.GetAttribute("longstart")); map.MapUsable = (int.Parse(mapXmlElement.GetAttribute("usable")) == 1); foreach (XmlElement anchorXmlNode in mapXmlElement.GetElementsByTagName("anchor")) { GCMapAnchor anchorPoint = new GCMapAnchor(); anchorPoint.relX = double.Parse(anchorXmlNode.GetAttribute("relX")); anchorPoint.relY = double.Parse(anchorXmlNode.GetAttribute("relY")); anchorPoint.Location = anchorXmlNode.GetAttribute("title"); anchorPoint.Latitude = double.Parse(anchorXmlNode.GetAttribute("latitude")); anchorPoint.Longitude = double.Parse(anchorXmlNode.GetAttribute("longitude")); map.AnchorPoints.Add(anchorPoint); } map.RecalculateDimensions(); Maps.Add(map); } } } }