当前位置: 首页>>代码示例>>C#>>正文


C# PointF.FindClosest方法代码示例

本文整理汇总了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();
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:31,代码来源:MapBox.cs

示例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();
			}
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:21,代码来源:MapBox.cs

示例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();
				}
			}
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:22,代码来源:MapBox.cs

示例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();
			}
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:19,代码来源:MapBox.cs


注:本文中的System.Drawing.PointF.FindClosest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。