當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。