public void RefreshTargets() { // Updates location of each target icon based on worldMap offset and size if (targetIcons.Count == 0) { // Load icons from targets foreach (TargetElement te in Targetdeck.Targets) { if (te.Position.PositionType == PositionType.StaticLLA) { TargetIcon t = new TargetIcon(te); double longitude = te.Position.Ics[0]; double latitude = te.Position.Ics[1]; int controlX = Conversion.Longitude2Pixel(longitude, worldMap.Width); int controlY = Conversion.Latitude2Pixel(latitude, worldMap.Height); int iconX = worldMap.Location.X + controlX; int iconY = worldMap.Location.Y + controlY; t.Location = new Point(iconX / 2, iconY / 2); t.Parent = this; t.BringToFront(); targetIcons.Add(t); } } } foreach (TargetIcon t in targetIcons) { if (((TargetElement)t.Tag).Position.PositionType == Hsf.Utility.PositionType.StaticLLA) { double longitude = ((TargetElement)t.Tag).Position.Ics[0]; double latitude = ((TargetElement)t.Tag).Position.Ics[1]; int controlX = Conversion.Longitude2Pixel(longitude, worldMap.Width); int controlY = Conversion.Latitude2Pixel(latitude, worldMap.Height); int iconX = worldMap.Location.X + controlX; int iconY = worldMap.Location.Y + controlY; t.Location = new Point(iconX, iconY); } } }
public void AddNewTarget(double latitude, double longitude) { //TargetdeckComponent before = Targetdeck.Clone(); // Create new component (static LLA by default, since created on map) TargetElement newTarget = new TargetElement(); newTarget.Position.PositionType = Hsf.Utility.PositionType.StaticLLA; newTarget.Position.Ics[0] = longitude; newTarget.Position.Ics[1] = latitude; Targetdeck.Targets.Add(newTarget); // Create new icon double x = (longitude + 180.0) * worldMap.Size.Width / 360.0; double y = (-1.0 * latitude + 90.0) * worldMap.Size.Height / 180.0; TargetIcon newIcon = new TargetIcon(newTarget); newIcon.Location = new Point((int)x, (int)y); newIcon.Visible = true; targetIcons.Add(newIcon); Controls.Add(newIcon); newIcon.BringToFront(); // Add target node TreeNode targetNode = new TreeNode(newTarget.TargetName); Node.Nodes.Add(targetNode); // Create new target form to attach to node TargetForm newForm = new TargetForm(newTarget, MdiParent, targetNode); targetNode.Tag = newForm; // Register event //_mManager.RegisterEvent(before, hComponent, hComponent, "Add Target"); // Make sure target is displayed RefreshTargets(); }