public BodiesPair(RoundBodyModel body1, RoundBodyModel body2) { Body1 = body1; Body2 = body2; Id = Extensions.CalculateHash(body1.Id, body2.Id); }
public void GenerateBlackHole(int mass = 5000000) { var blackHole = new RoundBodyModel((ushort) (Bodies.Any() ? Bodies.Max(x => x.Id) + 1 : 1)) { Mass = new Mass(mass), CenterX = new Coordinate(MaxX/2), CenterY = new Coordinate(MaxY/2), }; blackHole.SetDiameter(); Bodies.ForEach(x => { var pair = new BodiesPair(blackHole, x); Pairs.Add(pair.Id, pair); }); Bodies.Add(blackHole); }
public void GenerateBodies(int count = BodiesCount) { var random = new Random(); for (int i = 0; i < count; i++) { var temp = new RoundBodyModel((ushort) i) { Mass = new Mass(random.Next(MaxMass)), CenterX = new Coordinate(random.Next(MaxX)), CenterY = new Coordinate(random.Next(MaxY)), Speed = new Speed(random.Next(-MaxSpeed, MaxSpeed), random.Next(-MaxSpeed, MaxSpeed)) }; temp.SetDiameter(); Bodies.ForEach(x => { var pair = new BodiesPair(x, temp); Pairs.Add(pair.Id, pair); }); Bodies.Add(temp); } }
public void OnBodyClicked(RoundBodyModel body, Point mousePosition) { body.CenterX.Value = mousePosition.X; body.CenterY.Value = mousePosition.Y; OnPropertyChanged(body, "Top"); OnPropertyChanged(body, "Left"); }
private void UIElement_OnPreviewMouseUp(object sender, MouseButtonEventArgs e) { _selected = null; }
private void UIElement_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { _selected = (RoundBodyModel)((FrameworkElement)sender).DataContext; }