public void DrawBouy(Bouy bouy,GraphicsDevice device, Camera camera) { foreach (ModelMesh mesh in _bouyModel.Meshes) { foreach (BasicEffect mfx in mesh.Effects) { //mfx.DiffuseColor = new Vector3(255, 128, 64); mfx.EnableDefaultLighting(); mfx.AmbientLightColor = new Vector3(1, 0.5f, 0); mfx.DiffuseColor = new Vector3(1, 0.5f, 0); mfx.SpecularColor = new Vector3(1, 0.5f, 0); mfx.World = Matrix.CreateScale(0.1f) * Matrix.CreateTranslation(ProjectedPointToWorld(bouy.CoordinatePoint.Project())); camera.ConfigureBasicEffect(mfx); } mesh.Draw(); } }
private Bouy NewBouy(Mark m) { CoordinatePoint bouyC = ScreenToCoordinates(new Point(lakePNL.Width / 2, lakePNL.Height / 2)); Bouy b = new Bouy(m, bouyC.Latitude, bouyC.Longitude); b.Save(); return b; }
private void FindClosestBouy(Point p) { Bouy b=null; if(TryFindCloseBouy(p,ref b)) { _selectedBouy = b; for (int i = 0; i < marksLB.Items.Count; i++) { if (((Mark)marksLB.Items[i]).Id == b.Mark.Id) { marksLB.SelectedIndex = i; } } } }
private void LoadSelectedMark() { if (SelectedMark != null) { editMarkGB.Enabled = true; removeBTN.Enabled = true; markNameTB.Text = SelectedMark.Name; markTypeCB.SelectedItem = SelectedMark.MarkType; mouseCoordsLBL.Text = SelectedMark.Bouys[0].Latitude.ToString() + " " + SelectedMark.Bouys[0].Longitude.ToString(); _selectedBouy = SelectedMark.Bouys[0]; lakePNL.Invalidate(); } else { editMarkGB.Enabled = false; removeBTN.Enabled = false; } }
private bool TryFindCloseBouy(Point p,ref Bouy closest) { List<Bouy> bouys = new List<Bouy>(); foreach (object o in marksLB.Items) { bouys.AddRange(((Mark)o).Bouys); } double maximumDistance = 10.0; double closestDistance = maximumDistance; Bouy closestBouy = null; foreach (Bouy b in bouys) { Point onScreen = CoordinatesToScreen(new CoordinatePoint(b.Latitude, b.Longitude, 0)); double distance = TwoDimensionalDistance(p.X, p.Y, onScreen.X, onScreen.Y); if (distance < closestDistance) { closestDistance = distance; closestBouy = b; } } if (closestBouy != null) { closest = closestBouy; return true; } else { closest = null; return false; } }