void RemoveLink(PointF locationF) { var g = GalaxyMap.Instance.Galaxy; if (g.Planets.Count < 2) { return; } if (selectedPlanetDrawing == null) { selectedPlanetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); Redraw(); } else { var planetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); var link = GalaxyMap.Instance.Galaxy.Links.SingleOrDefault( l => g.GetPlanets(l).Contains(planetDrawing.Planet) && g.GetPlanets(l).Contains(selectedPlanetDrawing.Planet)); if (link != null) { g.Links.Remove(link); } selectedPlanetDrawing = null; Redraw(); } }
void DoClick(MouseEventArgs e) { var locationF = new PointF((float)e.Location.X/PictureBox.Width, (float)e.Location.Y/PictureBox.Height); var b = MainForm.Instance.lastClicked; if (b == null || b == MainForm.Instance.btn_SelectPlanet) { if (!GalaxyMap.Instance.PlanetDrawings.Any()) { return; } var planetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); selectedPlanetDrawing = planetDrawing; Redraw(); if (planetDrawing.Map == null) { return; } var myPlanet = planetDrawing.Planet.OwnerName == Program.AuthInfo.Login; new PlanetInfoForm( planetDrawing, myPlanet && !GalaxyMap.Instance.Galaxy.GetPlayer(Program.AuthInfo.Login).HasChangedMap, myPlanet). Show(); return; } if (b == MainForm.Instance.btn_AddPlanet) { AddPlanet(locationF); } else if (b == MainForm.Instance.btn_RemovePlanet) { RemovePlanet(locationF); } else if (b == MainForm.Instance.btn_AddLink) { AddLink(locationF); } else if (b == MainForm.Instance.btn_RemoveLink) { RemoveLink(locationF); } GalaxyMap.Instance.Galaxy.CheckIntegrity(); }
void AddLink(PointF locationF) { if (GalaxyMap.Instance.PlanetDrawings.Count < 2) { return; } if (selectedPlanetDrawing == null) { selectedPlanetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); Redraw(); } else { var planetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); if ( !GalaxyMap.Instance.Galaxy.Links.Any( l => GalaxyMap.Instance.Galaxy.GetPlanets(l).Contains(planetDrawing.Planet) && GalaxyMap.Instance.Galaxy.GetPlanets(l).Contains(selectedPlanetDrawing.Planet))) { var link = new Link(selectedPlanetDrawing.Planet.ID, planetDrawing.Planet.ID); GalaxyMap.Instance.Galaxy.Links.Add(link); selectedPlanetDrawing = null; Redraw(); } } }
public PlanetInfoForm(PlanetDrawing planet, bool changeMap, bool changeName) { base.Text = "Planet Information"; ShowIcon = false; Width = 600; Height = 500; var mapButton = new ToolStripButton("Map Information"); var minimapButton = new ToolStripButton("Minimap"); var mapInfoView = new MapInfoView(planet.Map); var minimapBox = new MinimapBox(planet.Map, 1); var heightmapButton = new ToolStripButton("Heightmap"); var heightmapBox = new PictureBox { Image = planet.Map.HeightMap, Dock = DockStyle.Fill, SizeMode = PictureBoxSizeMode.Zoom, BackColor = Color.Black, }; var metalmapButton = new ToolStripButton("Metalmap"); var metalmapBox = new PictureBox { Image = planet.Map.MetalMap, Dock = DockStyle.Fill, SizeMode = PictureBoxSizeMode.Zoom, BackColor = Color.Black, }; var dict = new Dictionary <ToolStripButton, System.Windows.Forms.Control> { { minimapButton, minimapBox }, { heightmapButton, heightmapBox }, { metalmapButton, metalmapBox }, { mapButton, mapInfoView }, }; if (changeMap) { dict.Add(new ToolStripButton("Change Map"), new ChangeMapControl()); } if (changeName) { dict.Add(new ToolStripButton("Change Name"), new ChangeNameControl()); } var tabbedControls = new TabbedControls(dict); tabbedControls.OkCancelBar.Visible = false; tabbedControls.ToolTabs.Dock = DockStyle.Top; Controls.Add(tabbedControls); }
void DoClick(MouseEventArgs e) { var locationF = new PointF((float)e.Location.X / PictureBox.Width, (float)e.Location.Y / PictureBox.Height); var b = MainForm.Instance.lastClicked; if (b == null || b == MainForm.Instance.btn_SelectPlanet) { if (!GalaxyMap.Instance.PlanetDrawings.Any()) { return; } var planetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); selectedPlanetDrawing = planetDrawing; Redraw(); if (planetDrawing.Map == null) { return; } var myPlanet = planetDrawing.Planet.OwnerName == Program.AuthInfo.Login; new PlanetInfoForm( planetDrawing, myPlanet && !GalaxyMap.Instance.Galaxy.GetPlayer(Program.AuthInfo.Login).HasChangedMap, myPlanet). Show(); return; } if (b == MainForm.Instance.btn_AddPlanet) { AddPlanet(locationF); } else if (b == MainForm.Instance.btn_RemovePlanet) { RemovePlanet(locationF); } else if (b == MainForm.Instance.btn_AddLink) { AddLink(locationF); } else if (b == MainForm.Instance.btn_RemoveLink) { RemoveLink(locationF); } GalaxyMap.Instance.Galaxy.CheckIntegrity(); }
void RemovePlanet(PointF locationF) { if (!GalaxyMap.Instance.PlanetDrawings.Any()) { return; } var planetDrawing = locationF.FindClosest(GalaxyMap.Instance.PlanetDrawings); if (DialogResult.Yes == MessageBox.Show( "Do you want to delete planet " + planetDrawing.Planet.Name ?? "Unnamed" + "?", "Confirm Delete", MessageBoxButtons.YesNo)) { GalaxyMap.Instance.Galaxy.Planets.Remove(planetDrawing.Planet); GalaxyMap.Instance.PlanetDrawings.Remove(planetDrawing); GalaxyMap.Instance.Galaxy.Links.RemoveAll(l => l.PlanetIDs.Contains(planetDrawing.Planet.ID)); selectedPlanetDrawing = null; Program.MainForm.Text = GalaxyMap.Instance.Galaxy.Planets.Count().ToString(); Redraw(); } }