public void UpdateMarkerLocations() { // Convertion formula not required to recalculate everytime double a_x = m_TileSize.Width * (m_Zoom + (3 / 2)) - m_TileSize.Width / 2.0; double a_y = m_TileSize.Height * (m_Zoom + (3 / 2)) - m_TileSize.Height / 2.0; double b_x = (192.0 / m_TileSize.Width); double b_y = (192.0 / m_TileSize.Height); // Update all markers this.InvokeIfRequired(() => { for (int i = 0; i < m_Markers.Count; i++) { xMapControl Marker = m_Markers.GetAt(i); // Convertion SRCoord -> Point SRCoord coords = ((SREntity)Marker.Tag).GetRealtimePosition(); Point location = new Point((int)Math.Round((coords.PosX - ViewPoint.PosX) / b_x + a_x), (int)Math.Round((coords.PosY - ViewPoint.PosY) / b_y * (-1) + a_y)); // Fix center location.X -= Marker.Image.Size.Width / 2; location.Y -= Marker.Image.Size.Height / 2; // Update only if is required to avoid trigger repaint on control if (Marker.Location.X != location.X && Marker.Location.Y != location.Y) { Marker.Location = location; } } }); }
public void AddMarker(uint UniqueID, xMapControl Marker) { Marker.Name = this.Name + "_" + UniqueID; this.InvokeIfRequired(() => { Controls.Add(Marker); Controls.SetChildIndex(Marker, 1); m_Markers[UniqueID] = Marker; }); }
public void RemoveMarker(uint UniqueID) { xMapControl Marker = m_Markers[UniqueID]; if (Marker != null) { this.InvokeIfRequired(() => { this.Controls.RemoveByKey(Marker.Name); }); this.m_Markers.RemoveKey(UniqueID); } }