本文整理汇总了C#中System.Drawing.PointF.FindClosest方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.FindClosest方法的具体用法?C# PointF.FindClosest怎么用?C# PointF.FindClosest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了PointF.FindClosest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoClick
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();
}
示例2: RemoveLink
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();
}
}
示例3: AddLink
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();
}
}
}
示例4: RemovePlanet
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();
}
}